Skip to content

Commit 1745c8e

Browse files
authored
[MachinePipeliner] Fix instruction order with physical register (#99264)
dependencies in same cycle Dependency checks were insufficient when reordering instructions with physical register dependencies (i.e. Anti/Output dependencies). This could result in generating incorrect code.
1 parent 421c3fe commit 1745c8e

File tree

2 files changed

+459
-4
lines changed

2 files changed

+459
-4
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,9 +3049,10 @@ void SMSchedule::orderDependence(const SwingSchedulerDAG *SSD, SUnit *SU,
30493049
MoveUse = Pos;
30503050
}
30513051
// We did not handle HW dependences in previous for loop,
3052-
// and we normally set Latency = 0 for Anti deps,
3053-
// so may have nodes in same cycle with Anti denpendent on HW regs.
3054-
else if (S.getKind() == SDep::Anti && stageScheduled(*I) == StageInst1) {
3052+
// and we normally set Latency = 0 for Anti/Output deps,
3053+
// so may have nodes in same cycle with Anti/Output dependent on HW regs.
3054+
else if ((S.getKind() == SDep::Anti || S.getKind() == SDep::Output) &&
3055+
stageScheduled(*I) == StageInst1) {
30553056
OrderBeforeUse = true;
30563057
if ((MoveUse == 0) || (Pos < MoveUse))
30573058
MoveUse = Pos;
@@ -3060,7 +3061,9 @@ void SMSchedule::orderDependence(const SwingSchedulerDAG *SSD, SUnit *SU,
30603061
for (auto &P : SU->Preds) {
30613062
if (P.getSUnit() != *I)
30623063
continue;
3063-
if (P.getKind() == SDep::Order && stageScheduled(*I) == StageInst1) {
3064+
if ((P.getKind() == SDep::Order || P.getKind() == SDep::Anti ||
3065+
P.getKind() == SDep::Output) &&
3066+
stageScheduled(*I) == StageInst1) {
30643067
OrderAfterDef = true;
30653068
MoveDef = Pos;
30663069
}

0 commit comments

Comments
 (0)