[llvm] [AArch64] Allow LDR merge with same destination register by renaming (PR #71908)

Zhaoxuan Jiang via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 19 00:09:23 PST 2023


================
@@ -815,12 +815,11 @@ AArch64LoadStoreOpt::mergeNarrowZeroStores(MachineBasicBlock::iterator I,
   return NextI;
 }
 
-// Apply Fn to all instructions between MI and the beginning of the block, until
-// a def for DefReg is reached. Returns true, iff Fn returns true for all
-// visited instructions. Stop after visiting Limit iterations.
-static bool forAllMIsUntilDef(MachineInstr &MI, MCPhysReg DefReg,
-                              const TargetRegisterInfo *TRI, unsigned Limit,
-                              std::function<bool(MachineInstr &, bool)> &Fn) {
+static bool forAllMIsUntil(MachineInstr &MI,
+                           std::function<bool(MachineInstr &MI, bool)> Until,
----------------
nocchijiang wrote:

Sorry for the confusion made here. Initially I wanted to let `Until` decide whether to stop the reverse iteration (because the exit point is fixed for merging `ldr` - right at the first load). Later I realized that the first load must be the def thus the entire functions can be reused by just iterating from different MIs for store and load, leaving `Until` unused. I have corrected this in the latest commit.

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


More information about the llvm-commits mailing list