[llvm] Move SI Lower Control Flow Up (PR #159557)

Patrick Simmons via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 14:41:57 PDT 2025


================
@@ -323,6 +332,8 @@ void SILowerControlFlow::emitElse(MachineInstr &MI) {
   if (LV)
     LV->replaceKillInstruction(SrcReg, MI, *OrSaveExec);
 
+  move_ins_before_phis(*OrSaveExec);
----------------
linuxrocks123 wrote:

@alex-t, I am not seeing the problem.  The surrounding code makes clear that the insertion can only ever happen at block begin.  I did not change those lines.  Are you sure there is an issue here?

```
  MachineBasicBlock::iterator Start = MBB.begin();

  // This must be inserted before phis and any spill code inserted before the
  // else.
  Register SaveReg = MRI->createVirtualRegister(BoolRC);
  MachineInstr *OrSaveExec =
      BuildMI(MBB, Start, DL, TII->get(LMC.OrSaveExecOpc), SaveReg)
          .add(MI.getOperand(1)); // Saved EXEC
  if (LV)
    LV->replaceKillInstruction(SrcReg, MI, *OrSaveExec);

  moveInsBeforePhis(*OrSaveExec);
```

https://github.com/llvm/llvm-project/pull/159557


More information about the llvm-commits mailing list