From dc26dec331b85751324e4e19ae318d03229b1d1f Mon Sep 17 00:00:00 2001 From: Thomas Raoux Date: Thu, 7 May 2020 08:30:00 -0700 Subject: [ModuloSchedule] Fix epilogue peeling with illegal phi. When peeling out the epilogue we need to ignore illegal phis coming from stages greater than the producer stage. Otherwise we end up with circular phi dependencies. Differential Revision: https://reviews.llvm.org/D79581 --- llvm/lib/CodeGen/ModuloSchedule.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'llvm/lib/CodeGen/ModuloSchedule.cpp') diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp index 3fa2285..65dc11e 100644 --- a/llvm/lib/CodeGen/ModuloSchedule.cpp +++ b/llvm/lib/CodeGen/ModuloSchedule.cpp @@ -1440,11 +1440,15 @@ Register KernelRewriter::remapUse(Register Reg, MachineInstr &MI) { // immediately prior to pruning. auto RC = MRI.getRegClass(Reg); Register R = MRI.createVirtualRegister(RC); - BuildMI(*BB, MI, DebugLoc(), TII->get(TargetOpcode::PHI), R) - .addReg(IllegalPhiDefault.getValue()) - .addMBB(PreheaderBB) // Block choice is arbitrary and has no effect. - .addReg(LoopReg) - .addMBB(BB); // Block choice is arbitrary and has no effect. + MachineInstr *IllegalPhi = + BuildMI(*BB, MI, DebugLoc(), TII->get(TargetOpcode::PHI), R) + .addReg(IllegalPhiDefault.getValue()) + .addMBB(PreheaderBB) // Block choice is arbitrary and has no effect. + .addReg(LoopReg) + .addMBB(BB); // Block choice is arbitrary and has no effect. + // Illegal phi should belong to the producer stage so that it can be + // filtered correctly during peeling. + S.setStage(IllegalPhi, LoopProducerStage); return R; } -- cgit v1.1