[llvm] [AMDGPU] Update LiveVariables in SILowerControlFlow::combineMasks (PR #217844)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 02:25:43 PDT 2026
================
@@ -636,10 +638,29 @@ void SILowerControlFlow::combineMasks(MachineInstr &MI) {
return;
Register Reg = MI.getOperand(OpToReplace).getReg();
+ MachineInstr *Def = MRI->getUniqueVRegDef(Reg);
MI.removeOperand(OpToReplace);
MI.addOperand(*KeepOp);
- if (MRI->use_empty(Reg))
- MRI->getUniqueVRegDef(Reg)->eraseFromParent();
+
+ // The fold moves the last use of Reg and of the Def sources onto MI.
+ SmallSet<Register, 4> RecomputeLV;
+ if (LV) {
+ RecomputeLV.insert(Reg);
+ for (const MachineOperand &Op : Def->all_uses())
+ if (Op.getReg().isVirtual())
+ RecomputeLV.insert(Op.getReg());
+ }
+
+ if (MRI->use_empty(Reg)) {
+ if (OuterNext == Def->getIterator())
+ ++OuterNext;
+ Def->eraseFromParent();
+ }
+
+ if (LV)
----------------
aobolensk wrote:
Done
https://github.com/llvm/llvm-project/pull/217844
More information about the llvm-commits
mailing list