From 16e66f590132791c2bbd9b69594a3a7f56809ce7 Mon Sep 17 00:00:00 2001 From: Krzysztof Parzyszek Date: Mon, 26 Mar 2018 16:41:36 +0000 Subject: [PATCH] [Pipeliner] Fix renaming in pipeliner when eliminating phis 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/MachinePipeliner.cpp b/llvm/lib/CodeGen/MachinePipeliner.cpp index 2a438ec..a3c6003 100644 --- a/llvm/lib/CodeGen/MachinePipeliner.cpp +++ b/llvm/lib/CodeGen/MachinePipeliner.cpp @@ -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]; } -- 2.7.4