[llvm] [AMDGPU][NFC][SIInsertWaitcnts] Remove redundant checks for invalidate instructions (PR #166139)

Stephen Thomas via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 04:02:51 PST 2025


================
@@ -530,16 +544,6 @@ class SIInsertWaitcnts {
   // Return the appropriate VMEM_*_ACCESS type for Inst, which must be a VMEM
   // instruction.
   WaitEventType getVmemWaitEventType(const MachineInstr &Inst) const {
-    switch (Inst.getOpcode()) {
----------------
stepthomas wrote:

The primary motivation was the observation that line 2268 ends up checking for GLOBAL_INV, GLOBAL_WB or GLOBAL_WBINV twice, the first time to check if it is one of those instructions, and the second time to work out which wait counter should be used. I wanted to streamline those two checks into a single check. The secondary motivation is the observation that the remaining uses of getVmemWaitEventType() could not be invalidate/WB instructions, becayse either they had already been dealt with or excluded by previous checks, so checking for them again is silly.

If it's felt that getVmemWaitEventType() should be fully general purpose, it could use getInvOrWBWaitEventType() to check for those specific instructions, as of this patch, the remaining use cases mean it would be a redundant check.

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


More information about the llvm-commits mailing list