[llvm] [AMDGPU] Merge consecutive wait_alu instruction (PR #128916)

Carl Ritson via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 7 01:34:14 PST 2025


================
@@ -362,6 +388,17 @@ class AMDGPUWaitSGPRHazards {
           Mask = AMDGPU::DepCtr::encodeFieldVaSdst(Mask, 0);
         }
         if (Emit) {
+          if (MI != MBB.instr_begin()) {
+            MachineBasicBlock::instr_iterator It = std::prev(MI);
+            while (It != MBB.instr_begin() && It->isDebugInstr())
+              --It;
+            if (It->getOpcode() == AMDGPU::S_WAITCNT_DEPCTR) {
+              Mask = mergeMasks(Mask, It->getOperand(0).getImm());
+              It->getOperand(0).setImm(Mask);
+              continue;
----------------
perlfu wrote:

Yes code below should not be skipped.

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


More information about the llvm-commits mailing list