diff --git a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp --- a/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp +++ b/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp @@ -294,6 +294,8 @@ if (MRI.isConstantPhysReg(Reg)) return; + const TargetSubtargetInfo &ST = MF.getSubtarget(); + // Optionally add output and anti dependencies. For anti // dependencies we use a latency of 0 because for a multi-issue // target we want to allow the defining instruction to issue @@ -311,14 +313,12 @@ if (DefSU != SU && (Kind != SDep::Output || !MO.isDead() || !DefSU->getInstr()->registerDefIsDead(*Alias))) { - if (Kind == SDep::Anti) - DefSU->addPred(SDep(SU, Kind, /*Reg=*/*Alias)); - else { - SDep Dep(SU, Kind, /*Reg=*/*Alias); + SDep Dep(SU, Kind, /*Reg=*/*Alias); + if (Kind != SDep::Anti) Dep.setLatency( SchedModel.computeOutputLatency(MI, OperIdx, DefSU->getInstr())); - DefSU->addPred(Dep); - } + ST.adjustSchedDependency(SU, OperIdx, DefSU, I->OpIdx, Dep); + DefSU->addPred(Dep); } } }