[llvm] df6e380 - [AArch64] Minor simplification in aarch64-ldst-opt with an early return (#207182)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 3 05:13:06 PDT 2026


Author: Ömer Sinan Ağacan
Date: 2026-07-03T13:13:01+01:00
New Revision: df6e3809d218f42f17a3c90f31498b01b0122346

URL: https://github.com/llvm/llvm-project/commit/df6e3809d218f42f17a3c90f31498b01b0122346
DIFF: https://github.com/llvm/llvm-project/commit/df6e3809d218f42f17a3c90f31498b01b0122346.diff

LOG: [AArch64] Minor simplification in aarch64-ldst-opt with an early return (#207182)

Remove the local `MBBIWithRenameReg` by moving an early return at an
even earlier point.

When `MBBIWithRenameReg` is set we always return early. By moving the
early return to `MBBIWithRenameReg` update we get rid of a local
variable which spans  200+ lines. This also fixes a misleading debug
print between `MBBIWithRenameReg` update and early return:

```
LLVM_DEBUG(dbgs() << "Unable to combine these instructions due to "
                << "interference in between, keep looking.\n");
```

This line shouldn't be printed when we set `MBBIWithRenameReg`, which is
fixed with this change.

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
index 0bca89815365f..bd0b603cfc06f 100644
--- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -2017,7 +2017,6 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
                                       bool FindNarrowMerge) {
   MachineBasicBlock::iterator E = I->getParent()->end();
   MachineBasicBlock::iterator MBBI = I;
-  MachineBasicBlock::iterator MBBIWithRenameReg;
   MachineInstr &FirstMI = *I;
   MBBI = next_nodbg(MBBI, E);
 
@@ -2247,7 +2246,7 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
           if (RenameReg) {
             Flags.setMergeForward(true);
             Flags.setRenameReg(*RenameReg);
-            MBBIWithRenameReg = MBBI;
+            return MBBI;
           }
         }
         LLVM_DEBUG(dbgs() << "Unable to combine these instructions due to "
@@ -2255,9 +2254,6 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
       }
     }
 
-    if (Flags.getRenameReg())
-      return MBBIWithRenameReg;
-
     // If the instruction wasn't a matching load or store.  Stop searching if we
     // encounter a call instruction that might modify memory.
     if (MI.isCall()) {


        


More information about the llvm-commits mailing list