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

Akash Dutta via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 06:33:32 PDT 2025


================
@@ -9743,6 +9743,90 @@ MachineInstr *llvm::getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P,
   return nullptr;
 }
 
+// helper function to checkIfExecMayBeModifiedBeforeUseAcrossBB and
+// execMayBeModifiedBeforeUse. This checks possible EXEC register modifications
+// for a straight-line sequence of instructions between BeginIterator and
+// EndIterator (both inclusive) upto a pre-defined limit MaxInstScan
+bool execMayBeModifiedBeforeUseUtil(
+    const TargetRegisterInfo *TRI,
+    const MachineInstrBundleIterator<const MachineInstr> BeginIterator,
+    const MachineInstrBundleIterator<const MachineInstr> EndIterator,
+    const int MaxInstScan) {
+
+  int NumInst = 0;
+  for (auto I = BeginIterator; I != EndIterator; ++I) {
+    if (I->isDebugInstr())
----------------
akadutta wrote:

Existing code uses isDebugInstr for checking within a basic block. 

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


More information about the llvm-commits mailing list