Fix a major bug in operand latency computation. The use index must be adjusted
authorEvan Cheng <evan.cheng@apple.com>
Thu, 28 Oct 2010 01:46:29 +0000 (01:46 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 28 Oct 2010 01:46:29 +0000 (01:46 +0000)
by the number of defs first for it to match the instruction itinerary.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117518 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp

index 0ffb4da0f3613d3dc044094f42f7629526cd533f..d34a52d80144997a85a1d7939dbef19eb883fdc6 100644 (file)
@@ -454,6 +454,9 @@ void ScheduleDAGSDNodes::ComputeOperandLatency(SDNode *Def, SDNode *Use,
     return;
 
   unsigned DefIdx = Use->getOperand(OpIdx).getResNo();
+  if (Use->isMachineOpcode())
+    // Adjust the use operand index by num of defs.
+    OpIdx += TII->get(Use->getMachineOpcode()).getNumDefs();
   int Latency = TII->getOperandLatency(InstrItins, Def, DefIdx, Use, OpIdx);
   if (Latency >= 0)
     dep.setLatency(Latency);