[llvm] [AMDGPU] Mark ASYNCMARK as meta instruction to fix hazard cycle miscounting (PR #189981)

Sameer Sahasrabuddhe via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 23:34:04 PDT 2026


================
@@ -223,6 +223,13 @@ static const unsigned
         AMDGPU::S_WAIT_KMCNT,     AMDGPU::S_WAIT_XCNT,
         AMDGPU::S_WAIT_ASYNCCNT};
 
+// ASYNCMARK and WAIT_ASYNCMARK are meta instructions that emit no hardware
+// code but still need to be processed by this pass for async vmcnt tracking.
+static bool isNonWaitcntMetaInst(const MachineInstr &MI) {
+  return MI.isMetaInstruction() && MI.getOpcode() != AMDGPU::ASYNCMARK &&
+         MI.getOpcode() != AMDGPU::WAIT_ASYNCMARK;
+}
+
----------------
ssahasra wrote:

The following is more readable. It avoids the repeated calls to `getOpcode()`, and it brings the exceptions up front.

```suggestion
static bool shouldSkipForWaitcnt(const MachineInstr &MI) {
  switch (MI.getOpcode()) {
    case AMDGPU::ASYNCMARK:
    case AMDGPU::WAIT_ASYNCMARK:
      return false;
    default:
      return MI.isMetaInstruction();
  }
}
```

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


More information about the llvm-commits mailing list