[llvm] [AArch64LoadStoreOpt] BaseReg update is searched also in CF successor (PR #145583)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 03:51:13 PDT 2025


================
@@ -2529,30 +2529,63 @@ MachineBasicBlock::iterator AArch64LoadStoreOpt::findMatchingUpdateInsnForward(
     return E;
   }
 
-  for (unsigned Count = 0; MBBI != E && Count < Limit;
-       MBBI = next_nodbg(MBBI, E)) {
-    MachineInstr &MI = *MBBI;
-
-    // Don't count transient instructions towards the search limit since there
-    // may be different numbers of them if e.g. debug information is present.
-    if (!MI.isTransient())
-      ++Count;
-
-    // If we found a match, return it.
-    if (isMatchingUpdateInsn(*I, MI, BaseReg, UnscaledOffset))
-      return MBBI;
-
-    // Update the status of what the instruction clobbered and used.
-    LiveRegUnits::accumulateUsedDefed(MI, ModifiedRegUnits, UsedRegUnits, TRI);
+  MachineBasicBlock *CurMBB = I->getParent();
+  // choice of next block to visit is liveins-based
+  bool VisitSucc = CurMBB->getParent()->getRegInfo().tracksLiveness();
+
+  while (true) {
----------------
john-brawn-arm wrote:

It looks like this could potentially loop forever, though I haven't come up with an example where this happens. Maybe it would be better to make this a "for (Count = 0; Count < Limit;)", as I think it makes sense for the limit to apply to all instructions searched not just those in a single block.

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


More information about the llvm-commits mailing list