Skip to content

Commit cbd64f7

Browse files
author
Jinsong Ji
committed
[MachinePipeliner] Fix Phi refers to Phi in same stage in 1st epilogue
Summary: This is exposed by functional testing on PowerPC. In some pipelined loops, Phi refer to phi did not get value defined by the Phi, hence getting wrong value later. As the comment mentioned, we should "use the value defined by the Phi, unless we're generating the firstepilog and the Phi refers to a Phi in a different stage.", so Phi refering to same stage Phi should use the value defined by the Phi here. Reviewers: bcahoon, hfinkel Reviewed By: hfinkel Subscribers: MaskRay, wuzish, nemanjai, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64035 llvm-svn: 365428
1 parent 18301fa commit cbd64f7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2430,7 +2430,7 @@ void SwingSchedulerDAG::generateExistingPhis(
24302430
// Use the value defined by the Phi, unless we're generating the first
24312431
// epilog and the Phi refers to a Phi in a different stage.
24322432
else if (VRMap[PrevStage - np].count(Def) &&
2433-
(!LoopDefIsPhi || PrevStage != LastStageNum))
2433+
(!LoopDefIsPhi || (PrevStage != LastStageNum) || (LoopValStage == StageScheduled)))
24342434
PhiOp2 = VRMap[PrevStage - np][Def];
24352435
}
24362436

llvm/test/CodeGen/PowerPC/sms-phi.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define dso_local void @sha512() #0 {
88
;CHECK: epilog:
99
;CHECK: %23:g8rc_and_g8rc_nox0 = PHI %5:g8rc_and_g8rc_nox0, %bb.3, %18:g8rc_and_g8rc_nox0, %bb.4
1010
;CHECK-NEXT: %24:g8rc = PHI %6:g8rc, %bb.3, %16:g8rc, %bb.4
11-
;CHECK-NEXT: %25:g8rc = PHI %6:g8rc, %bb.3, %16:g8rc, %bb.4
11+
;CHECK-NEXT: %25:g8rc = PHI %6:g8rc, %bb.3, %19:g8rc, %bb.4
1212
br label %1
1313

1414
1: ; preds = %1, %0

0 commit comments

Comments
 (0)