Index: llvm/include/llvm/CodeGen/TargetSubtargetInfo.h =================================================================== --- llvm/include/llvm/CodeGen/TargetSubtargetInfo.h +++ llvm/include/llvm/CodeGen/TargetSubtargetInfo.h @@ -226,7 +226,8 @@ // Perform target specific adjustments to the latency of a schedule // dependency. - virtual void adjustSchedDependency(SUnit *def, SUnit *use, SDep &dep) const {} + virtual void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, + int UseOpIdx, SDep &Dep) const {} // For use with PostRAScheduling: get the anti-dependence breaking that should // be performed before post-RA scheduling. Index: llvm/lib/CodeGen/MachinePipeliner.cpp =================================================================== --- llvm/lib/CodeGen/MachinePipeliner.cpp +++ llvm/lib/CodeGen/MachinePipeliner.cpp @@ -806,7 +806,7 @@ if (!MI->isPHI()) { SDep Dep(SU, SDep::Data, Reg); Dep.setLatency(0); - ST.adjustSchedDependency(SU, &I, Dep); + ST.adjustSchedDependency(SU, 0, &I, MI->getOperandNo(MOI), Dep); I.addPred(Dep); } else { HasPhiUse = Reg; Index: llvm/lib/CodeGen/ScheduleDAGInstrs.cpp =================================================================== --- llvm/lib/CodeGen/ScheduleDAGInstrs.cpp +++ llvm/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -269,13 +269,13 @@ if (!ImplicitPseudoDef && !ImplicitPseudoUse) { Dep.setLatency(SchedModel.computeOperandLatency(SU->getInstr(), OperIdx, RegUse, UseOp)); - ST.adjustSchedDependency(SU, UseSU, Dep); + ST.adjustSchedDependency(SU, OperIdx, UseSU, UseOp, Dep); } else { Dep.setLatency(0); // FIXME: We could always let target to adjustSchedDependency(), and // remove this condition, but that currently asserts in Hexagon BE. if (SU->getInstr()->isBundle() || (RegUse && RegUse->isBundle())) - ST.adjustSchedDependency(SU, UseSU, Dep); + ST.adjustSchedDependency(SU, OperIdx, UseSU, UseOp, Dep); } UseSU->addPred(Dep); @@ -444,7 +444,7 @@ SDep Dep(SU, SDep::Data, Reg); Dep.setLatency(SchedModel.computeOperandLatency(MI, OperIdx, Use, I->OperandIndex)); - ST.adjustSchedDependency(SU, UseSU, Dep); + ST.adjustSchedDependency(SU, OperIdx, UseSU, I->OperandIndex, Dep); UseSU->addPred(Dep); } Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp +++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp @@ -474,6 +474,7 @@ for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) { SDNode *OpN = N->getOperand(i).getNode(); + unsigned DefIdx = N->getOperand(i).getResNo(); if (isPassiveNode(OpN)) continue; // Not scheduled. SUnit *OpSU = &SUnits[OpN->getNodeId()]; assert(OpSU && "Node has no SUnit!"); @@ -508,7 +509,7 @@ Dep.setLatency(OpLatency); if (!isChain && !UnitLatencies) { computeOperandLatency(OpN, N, i, Dep); - ST.adjustSchedDependency(OpSU, SU, Dep); + ST.adjustSchedDependency(OpSU, DefIdx, SU, i, Dep); } if (!SU->addPred(Dep) && !Dep.isCtrl() && OpSU->NumRegDefsLeft > 1) { Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h +++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h @@ -1239,7 +1239,8 @@ return AMDGPU::IsaInfo::getMinWavesPerEU(this); } - void adjustSchedDependency(SUnit *Src, SUnit *Dst, SDep &Dep) const override; + void adjustSchedDependency(SUnit *Src, int SrcOpIdx, SUnit *Dst, int DstOpIdx, + SDep &Dep) const override; }; class R600Subtarget final : public R600GenSubtargetInfo, Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp @@ -742,8 +742,8 @@ return MaxNumVGPRs; } -void GCNSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, - SDep &Dep) const { +void GCNSubtarget::adjustSchedDependency(SUnit *Src, int SrcOpIdx, SUnit *Dst, + int DstOpIdx, SDep &Dep) const { if (Dep.getKind() != SDep::Kind::Data || !Dep.getReg() || !Src->isInstr() || !Dst->isInstr()) return; Index: llvm/lib/Target/Hexagon/HexagonSubtarget.h =================================================================== --- llvm/lib/Target/Hexagon/HexagonSubtarget.h +++ llvm/lib/Target/Hexagon/HexagonSubtarget.h @@ -258,7 +258,8 @@ /// Perform target specific adjustments to the latency of a schedule /// dependency. - void adjustSchedDependency(SUnit *def, SUnit *use, SDep& dep) const override; + void adjustSchedDependency(SUnit *Def, int DefOpIdx, SUnit *Use, int UseOpIdx, + SDep &Dep) const override; unsigned getVectorLength() const { assert(useHVXOps()); Index: llvm/lib/Target/Hexagon/HexagonSubtarget.cpp =================================================================== --- llvm/lib/Target/Hexagon/HexagonSubtarget.cpp +++ llvm/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -315,7 +315,8 @@ /// Perform target specific adjustments to the latency of a schedule /// dependency. -void HexagonSubtarget::adjustSchedDependency(SUnit *Src, SUnit *Dst, +void HexagonSubtarget::adjustSchedDependency(SUnit *Src, int SrcOpIdx, + SUnit *Dst, int DstOpIdx, SDep &Dep) const { MachineInstr *SrcInst = Src->getInstr(); MachineInstr *DstInst = Dst->getInstr();