[Pipeliner] Fix renaming in pipeliner when eliminating phis
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Mon, 26 Mar 2018 16:41:36 +0000 (16:41 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Mon, 26 Mar 2018 16:41:36 +0000 (16:41 +0000)
The phi renaming code in the pipeliner uses the wrong value when
rewriting phi uses, which results in an undefined value. In this
case, the original phi is no longer needed due to the order of
instruction in the pipelined loop. The pipeliner was assuming, in
this case, the the phi loop definition should be used to
rewrite the uses. However, the pipeliner needs to check to make
sure that the loop definition has already been scheduled. If not,
then the phi initial value needs to be used instead.

Patch by Brendon Cahoon.

llvm-svn: 328545

llvm/lib/CodeGen/MachinePipeliner.cpp

index 2a438ec..a3c6003 100644 (file)
@@ -2624,7 +2624,7 @@ void SwingSchedulerDAG::generateExistingPhis(
       // of the Phi value.
       unsigned NewReg = VRMap[PrevStage][LoopVal];
       rewriteScheduledInstr(NewBB, Schedule, InstrMap, CurStageNum, 0, &*BBI,
-                            Def, NewReg);
+                            Def, InitVal, NewReg);
       if (VRMap[CurStageNum].count(LoopVal))
         VRMap[CurStageNum][Def] = VRMap[CurStageNum][LoopVal];
     }