[llvm] [AMDGPU] Clear kills for aliasing registers after forming V_CMPX (PR #68675)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 01:46:39 PDT 2023


================
@@ -594,10 +594,14 @@ bool SIOptimizeExecMasking::optimizeVCMPSaveExecSequence(
   TryAddImmediateValueFromNamedOperand(AMDGPU::OpName::clamp);
 
   // The kill flags may no longer be correct.
-  if (Src0->isReg())
-    MRI->clearKillFlags(Src0->getReg());
-  if (Src1->isReg())
-    MRI->clearKillFlags(Src1->getReg());
+  if (Src0->isReg()) {
+    for (MCRegAliasIterator I(Src0->getReg(), TRI, true); I.isValid(); ++I)
----------------
jayfoad wrote:

I don't like introducing new uses of `MCRegAliasIterator` because it is potentially expensive, but it does seem like the simplest way to implement this fix.

An alternative might be to scan all operands of all instructions between the old v_cmp and the new v_cmpx, and clear kill flags if they overlap with Src0 or Src1.

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


More information about the llvm-commits mailing list