[llvm] [AMDGPU] SIFoldOperands: Delay foldCopyToVGPROfScalarAddOfFrameIndex (PR #141558)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 01:12:27 PDT 2025


================
@@ -1947,7 +1943,14 @@ bool SIFoldOperandsImpl::tryFoldFoldableCopy(
     Changed = true;
   }
 
-  return Changed;
+  if (Changed)
+    return true;
+
+  // Run this after foldInstOperand to avoid turning scalar additions into
+  // vector additions when the result scalar result could just be folded into
+  // the user(s).
+  return (OpToFold.isReg() &&
+          foldCopyToVGPROfScalarAddOfFrameIndex(DstReg, OpToFold.getReg(), MI));
----------------
arsenm wrote:

```suggestion
  return OpToFold.isReg() &&
          foldCopyToVGPROfScalarAddOfFrameIndex(DstReg, OpToFold.getReg(), MI);
```

Extra parentheses 

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


More information about the llvm-commits mailing list