[llvm] X86: Remove stale EFLAGS live range when converting ADD to LEA (PR #222029)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 01:24:31 PDT 2026


================
@@ -2042,7 +2046,11 @@ MachineInstr *X86InstrInfo::convertToThreeAddress(MachineInstr &MI,
   MBB.insert(MI.getIterator(), NewMI); // Insert the new inst
 
   if (LIS) {
+    // The replacement does not define EFLAGS; drop the dead EFLAGS def MI had.
+    SlotIndex Idx = LIS->getInstructionIndex(MI);
     LIS->ReplaceMachineInstrInMaps(MI, *NewMI);
+
+    LIS->removePhysRegDefAt(X86::EFLAGS, Idx.getRegSlot());
----------------
phoebewang wrote:

There are many vector instruction that don't def EFLAGS at all. Can we remove it regardless?

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


More information about the llvm-commits mailing list