From cbd64f7648fe491f20bba9840f7637196e07ccb7 Mon Sep 17 00:00:00 2001 From: Jinsong Ji Date: Tue, 9 Jul 2019 02:27:35 +0000 Subject: [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 --- llvm/lib/CodeGen/MachinePipeliner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp') diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 167c05f9ef4..9c0c5cc5c70 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -2430,7 +2430,7 @@ void SwingSchedulerDAG::generateExistingPhis( // 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]; } -- cgit v1.2.3