[llvm] [AMDGPU] Fix si-optimize-exec-masking stepping into debug values (PR #201947)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 02:07:39 PDT 2026


================
@@ -759,9 +764,14 @@ void SIOptimizeExecMasking::tryRecordOrSaveexecXorSequence(MachineInstr &MI) {
         XorSrc1.isReg() &&
         (XorSrc0.getReg() == LMC.ExecReg || XorSrc1.getReg() == LMC.ExecReg)) {
 
-      // Peek at the previous instruction and check if this is a relevant
-      // s_or_saveexec instruction.
-      MachineInstr &PossibleOrSaveexec = *MI.getPrevNode();
+      // Peek at the previous non-debug instruction and check if this is a
+      // relevant s_or_saveexec instruction.
+      MachineInstr *Prev = MI.getPrevNode();
+      while (Prev && Prev->isDebugInstr())
+        Prev = Prev->getPrevNode();
----------------
arsenm wrote:

skipDebugInstructionsBackward?

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


More information about the llvm-commits mailing list