aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePipeliner.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:10:48 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2018-03-26 16:10:48 +0000
commit55cb4986a47acd7296c0a026bd53a507baeb03a7 (patch)
tree41242c71b72076473a4c85583fb186a116ae7265 /llvm/lib/CodeGen/MachinePipeliner.cpp
parentaa40148cae6611fb8b30e5f51492d5f73ed3660b (diff)
downloadllvm-55cb4986a47acd7296c0a026bd53a507baeb03a7.zip
llvm-55cb4986a47acd7296c0a026bd53a507baeb03a7.tar.gz
llvm-55cb4986a47acd7296c0a026bd53a507baeb03a7.tar.bz2
[Pipeliner] Fix calculation when reusing phis
A schedule may require that a phi from the original loop is used in multiple iterations in the scheduled loop. When this occurs, we generate multiple phis in the pipelined loop to save the value across iterations. When we generate the new phis and update the register names in the pipelined loop, the pipeliner attempts to reuse a previously generated phi, when possible. The calculation for the name of the new phi needs to account for the version/iteration of the original phi. Also, in the epilog, the code only needs to check backwards for a previous iteration until reaching the first prolog block. Patch by Brendon Cahoon. llvm-svn: 328537
Diffstat (limited to 'llvm/lib/CodeGen/MachinePipeliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachinePipeliner.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp
index 2573eaf..e968f3a 100644
--- a/llvm/lib/CodeGen/MachinePipeliner.cpp
+++ b/llvm/lib/CodeGen/MachinePipeliner.cpp
@@ -2730,7 +2730,7 @@ void SwingSchedulerDAG::generateExistingPhis(
// references another Phi, and the other Phi is scheduled in an
// earlier stage. We can try to reuse an existing Phi up until the last
// stage of the current Phi.
- if (LoopDefIsPhi && (int)PrologStage >= StageScheduled) {
+ if (LoopDefIsPhi && (int)(PrologStage - np) >= StageScheduled) {
int LVNumStages = Schedule.getStagesForPhi(LoopVal);
int StageDiff = (StageScheduled - LoopValStage);
LVNumStages -= StageDiff;
@@ -2742,8 +2742,8 @@ void SwingSchedulerDAG::generateExistingPhis(
ReuseStage -= LVNumStages;
// Check if the Phi to reuse has been generated yet. If not, then
// there is nothing to reuse.
- if (VRMap[ReuseStage].count(LoopVal)) {
- NewReg = VRMap[ReuseStage][LoopVal];
+ if (VRMap[ReuseStage - np].count(LoopVal)) {
+ NewReg = VRMap[ReuseStage - np][LoopVal];
rewriteScheduledInstr(NewBB, Schedule, InstrMap, CurStageNum, np,
&*BBI, Def, NewReg);