[llvm] Address Codegen bug related to marking subregister MachineOperand defines as undef (PR #134929)

Ryan Buchner via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 12:12:59 PDT 2025


================
@@ -1570,6 +1570,29 @@ void LiveIntervals::handleMove(MachineInstr &MI, bool UpdateFlags) {
 
   HMEditor HME(*this, *MRI, *TRI, OldIndex, NewIndex, UpdateFlags);
   HME.updateAllRanges(&MI);
+
+  // Check to make sure that there are no subreg defintions marked undef
+  // after the moved operation. If so, mark the current instruction as undef
+  // instead.
+  for (MachineOperand &MO : MI.operands()) {
----------------
bababuck wrote:

I'm not sure if this simplifies the resulting code any if I'm understanding correctly. We can add the following:
```
if (!LI.liveAt(Index.getNextSlot()))
   MO.setIsUndef(true);
```
but this only works for flagging the moved instruction as `undef`, we still have to execute the same logic as before to remove the `undef` from the next definition of that register (if present).

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


More information about the llvm-commits mailing list