summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:37:55 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:37:55 +0000
commit3f72a6b7a1c616ae4f3c46b2c89a9da53fd24a51 (patch)
treeb44152f90843c459b6ea5f519d89870630d096dd /llvm/lib/CodeGen/MachinePipeliner.cpp
parenta212204453c61cd7fb48941dd9d08bfe120d11c1 (diff)
downloadbcm5719-llvm-3f72a6b7a1c616ae4f3c46b2c89a9da53fd24a51.tar.gz
bcm5719-llvm-3f72a6b7a1c616ae4f3c46b2c89a9da53fd24a51.zip
[Pipeliner] Fix number of phis to generate in the epilog
The pipeliner was generating too many phis in the epilog blocks, which caused incorrect code generation when rewriting an instruction that uses the phi. In this case, there 3 prolog and epilog stages. An existing phi was scheduled at stage 1. When generating the code for the 2nd epilog an extra new phi was generated. To fix this, we need to update the code that calculates the maximum number of phis that can be generated, which is based upon the current prolog stage and the stage of the original phi. In this case, when the prolog stage is 1 and the original phi stage is 1, the maximum number of phis to generate is 2. Patch by Brendon Cahoon. llvm-svn: 328543
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachinePipeliner.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 6f3440b661d..2a438eca92e 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -2629,16 +2629,13 @@ void SwingSchedulerDAG::generateExistingPhis(
VRMap[CurStageNum][Def] = VRMap[CurStageNum][LoopVal];
}
// Adjust the number of Phis needed depending on the number of prologs left,
- // and the distance from where the Phi is first scheduled.
- unsigned NumPhis = NumStages;
- if (!InKernel && (int)PrologStage < LoopValStage)
- // The NumPhis is the maximum number of new Phis needed during the steady
- // state. If the Phi has not been scheduled in current prolog, then we
- // need to generate less Phis.
- NumPhis = std::max((int)NumPhis - (int)(LoopValStage - PrologStage), 1);
- // The number of Phis cannot exceed the number of prolog stages. Each
- // stage can potentially define two values.
- NumPhis = std::min(NumPhis, PrologStage + 2);
+ // and the distance from where the Phi is first scheduled. The number of
+ // Phis cannot exceed the number of prolog stages. Each stage can
+ // potentially define two values.
+ unsigned MaxPhis = PrologStage + 2;
+ if (!InKernel && (int)PrologStage <= LoopValStage)
+ MaxPhis = std::max((int)MaxPhis - (int)LoopValStage, 1);
+ unsigned NumPhis = std::min(NumStages, MaxPhis);
unsigned NewReg = 0;
OpenPOWER on IntegriCloud