[llvm] [AMDGPU] Enable CSE in the GlobalISel post-legalizer combiner (PR #217258)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 19 03:18:53 PDT 2026


================
@@ -189,6 +189,13 @@ bool CombinerHelper::isConstantLegalOrBeforeLegalizer(const LLT Ty) const {
 
 void CombinerHelper::replaceRegWith(MachineRegisterInfo &MRI, Register FromReg,
                                     Register ToReg) const {
+  // constrainRegAttrs may change attributes that are part of the CSE profile
+  // for every instruction that references ToReg.
+  SmallVector<MachineInstr *, 4> ToRegInstrs;
+  for (MachineInstr &MI : MRI.reg_instructions(ToReg)) {
+    Observer.changingInstr(MI);
+    ToRegInstrs.push_back(&MI);
+  }
----------------
arsenm wrote:

Should not need to do this

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


More information about the llvm-commits mailing list