[llvm] [AArch64LoadStoreOptimizer] Pair far-offset loads/stores via base-register adjustment (PR #223684)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 18:55:11 PDT 2026


================
@@ -2047,6 +2131,31 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
   // Remember any instructions that read/write memory between FirstMI and MI.
   SmallVector<MachineInstr *, 4> MemInsns;
 
+  // Scratch availability at FirstMI, computed lazily and at most once per
+  // call. ModifiedRegUnits/UsedRegUnits only cover the region between the
+  // paired insns, so the base-adjust path needs the scavenger for sound
+  // liveness at FirstMI; without it, no scratch is picked.
+  BitVector AvailableScratchRegs;
+  bool ScavengerReady = false;
+  bool ScavengerComputed = false;
+  auto computeScratchAvailability = [&] {
+    if (ScavengerComputed)
+      return;
+    ScavengerComputed = true;
+    const MachineFunction &MF = *FirstMI.getParent()->getParent();
+    if (MF.getRegInfo().tracksLiveness()) {
+      RegScavenger RS;
----------------
whokeke wrote:

Just following up — does the explanation above (post-RA, no SSA def-use chain, scavenger lazily recomputed per candidate pair) address the concern, or is there a different design you'd prefer for the scratch-register lookup?

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


More information about the llvm-commits mailing list