[PATCH] D64035: [MachinePipeliner] Fix Phi refers to Phi in same stage in 1st epilogue
Jinsong Ji via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 14:16:23 PDT 2019
jsji created this revision.
jsji added reviewers: bcahoon, hfinkel.
Herald added subscribers: hiraditya, nemanjai.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64035
Files:
llvm/lib/CodeGen/MachinePipeliner.cpp
llvm/test/CodeGen/PowerPC/sms-phi.ll
Index: llvm/test/CodeGen/PowerPC/sms-phi.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/sms-phi.ll
+++ llvm/test/CodeGen/PowerPC/sms-phi.ll
@@ -8,7 +8,7 @@
;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
Index: llvm/lib/CodeGen/MachinePipeliner.cpp
===================================================================
--- llvm/lib/CodeGen/MachinePipeliner.cpp
+++ llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -2430,7 +2430,7 @@
// 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];
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64035.207408.patch
Type: text/x-patch
Size: 1253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190701/a954f347/attachment.bin>
More information about the llvm-commits
mailing list