[llvm] r365428 - [MachinePipeliner] Fix Phi refers to Phi in same stage in 1st epilogue
Jinsong Ji via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 8 19:27:35 PDT 2019
Author: jsji
Date: Mon Jul 8 19:27:35 2019
New Revision: 365428
URL: http://llvm.org/viewvc/llvm-project?rev=365428&view=rev
Log:
[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
Modified:
llvm/trunk/lib/CodeGen/MachinePipeliner.cpp
llvm/trunk/test/CodeGen/PowerPC/sms-phi.ll
Modified: llvm/trunk/lib/CodeGen/MachinePipeliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachinePipeliner.cpp?rev=365428&r1=365427&r2=365428&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachinePipeliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachinePipeliner.cpp Mon Jul 8 19:27:35 2019
@@ -2430,7 +2430,7 @@ void SwingSchedulerDAG::generateExisting
// Use the value defined by the Phi, unless we're generating the first
// epilog and the Phi refers to a Phi in a different stage.
else if (VRMap[PrevStage - np].count(Def) &&
- (!LoopDefIsPhi || PrevStage != LastStageNum))
+ (!LoopDefIsPhi || (PrevStage != LastStageNum) || (LoopValStage == StageScheduled)))
PhiOp2 = VRMap[PrevStage - np][Def];
}
Modified: llvm/trunk/test/CodeGen/PowerPC/sms-phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/sms-phi.ll?rev=365428&r1=365427&r2=365428&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/sms-phi.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/sms-phi.ll Mon Jul 8 19:27:35 2019
@@ -8,7 +8,7 @@ define dso_local void @sha512() #0 {
;CHECK: epilog:
;CHECK: %23:g8rc_and_g8rc_nox0 = PHI %5:g8rc_and_g8rc_nox0, %bb.3, %18:g8rc_and_g8rc_nox0, %bb.4
;CHECK-NEXT: %24:g8rc = PHI %6:g8rc, %bb.3, %16:g8rc, %bb.4
-;CHECK-NEXT: %25:g8rc = PHI %6:g8rc, %bb.3, %16:g8rc, %bb.4
+;CHECK-NEXT: %25:g8rc = PHI %6:g8rc, %bb.3, %19:g8rc, %bb.4
br label %1
1: ; preds = %1, %0
More information about the llvm-commits
mailing list