[llvm] [AMDGPU] Fix s_singleuse_vdst not detecing exec mask changes (PR #89401)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 09:27:22 PDT 2024


================
@@ -112,7 +112,7 @@ class AMDGPUInsertSingleUseVDST : public MachineFunctionPass {
 
           // Reset uses count when a register is no longer live.
           for (const MCRegUnit &Unit : RegUnits)
-            RegisterUseCount.erase(Unit);
+            RegisterUseCount[Unit] = 0;
----------------
jayfoad wrote:

It's really hard to understand the effect of this change because of other problems in this loop-over-the-operands.

1. The `modifiesRegister` check on line 104 is odd because it checks if _any_ operand of the current instruction modifies Reg, not just the current operand. Can it just check `Operand.isDef()` instead?

2. Really the loop should be split into two processing defs first and then uses. I think you had a downstream patch to do that.

Could you post a patch to fix either (1) or (2) first, and then we can revisit this one?

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


More information about the llvm-commits mailing list