[llvm] AMDGPU: Allow operand folding between loop body and its preheader (PR #137022)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 11:47:35 PDT 2025


================
@@ -1168,10 +1178,10 @@ void SIFoldOperandsImpl::foldOperand(
       }
 
       if (OpToFold.isReg() && TRI->isSGPRReg(*MRI, OpToFold.getReg())) {
-        if (execMayBeModifiedBeforeUse(*MRI,
-                                       UseMI->getOperand(UseOpIdx).getReg(),
-                                       *OpToFold.getParent(),
-                                       *UseMI))
+        if (checkIfExecMayBeModifiedBeforeUseAcrossBB(
+                *MRI, UseMI->getOperand(UseOpIdx).getReg(),
+                *OpToFold.getParent(), *UseMI, SIFoldOperandsPreheader,
+                SIFoldOperandsPreheaderThreshold))
           return;
----------------
arsenm wrote:

It would be a lot better if we didn't have to add all this complexity for just this one case

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


More information about the llvm-commits mailing list