[llvm] d7d2a55 - [AArch64] Add an early return and de-indent a long indented block (NFC) (#201345)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 02:58:33 PDT 2026
Author: Ömer Sinan Ağacan
Date: 2026-06-05T10:58:28+01:00
New Revision: d7d2a558253250a087fe9b9b21abfc111e91425b
URL: https://github.com/llvm/llvm-project/commit/d7d2a558253250a087fe9b9b21abfc111e91425b
DIFF: https://github.com/llvm/llvm-project/commit/d7d2a558253250a087fe9b9b21abfc111e91425b.diff
LOG: [AArch64] Add an early return and de-indent a long indented block (NFC) (#201345)
As per LLVM coding standards recommendation in [1].
[1]:
https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
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 290fe824d1625..2d9b8eb06b7cd 100644
--- a/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
@@ -2879,52 +2879,52 @@ bool AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
LdStPairFlags Flags;
MachineBasicBlock::iterator Paired =
findMatchingInsn(MBBI, Flags, LdStLimit, /* FindNarrowMerge = */ false);
- if (Paired != E) {
- // Keeping the iterator straight is a pain, so we let the merge routine tell
- // us what the next instruction is after it's done mucking about.
- auto Prev = std::prev(MBBI);
-
- // Fetch the memoperand of the load/store that is a candidate for
- // combination.
- MachineMemOperand *MemOp =
- MI.memoperands_empty() ? nullptr : MI.memoperands().front();
-
- // If a load/store arrives and ldp/stp-aligned-only feature is opted, check
- // that the alignment of the source pointer is at least double the alignment
- // of the type.
- if ((MI.mayLoad() && Subtarget->hasLdpAlignedOnly()) ||
- (MI.mayStore() && Subtarget->hasStpAlignedOnly())) {
- // If there is no size/align information, cancel the transformation.
- if (!MemOp || !MemOp->getMemoryType().isValid()) {
- NumFailedAlignmentCheck++;
- return false;
- }
- // Get the needed alignments to check them if
- // ldp-aligned-only/stp-aligned-only features are opted.
- uint64_t MemAlignment = MemOp->getAlign().value();
- uint64_t TypeAlignment =
- Align(MemOp->getSize().getValue().getKnownMinValue()).value();
+ if (Paired == E)
+ return false;
- if (MemAlignment < 2 * TypeAlignment) {
- NumFailedAlignmentCheck++;
- return false;
- }
+ // Keeping the iterator straight is a pain, so we let the merge routine tell
+ // us what the next instruction is after it's done mucking about.
+ auto Prev = std::prev(MBBI);
+
+ // Fetch the memoperand of the load/store that is a candidate for combination.
+ MachineMemOperand *MemOp =
+ MI.memoperands_empty() ? nullptr : MI.memoperands().front();
+
+ // If a load/store arrives and ldp/stp-aligned-only feature is opted, check
+ // that the alignment of the source pointer is at least double the alignment
+ // of the type.
+ if ((MI.mayLoad() && Subtarget->hasLdpAlignedOnly()) ||
+ (MI.mayStore() && Subtarget->hasStpAlignedOnly())) {
+ // If there is no size/align information, cancel the transformation.
+ if (!MemOp || !MemOp->getMemoryType().isValid()) {
+ NumFailedAlignmentCheck++;
+ return false;
}
- ++NumPairCreated;
- if (TII->hasUnscaledLdStOffset(MI))
- ++NumUnscaledPairCreated;
-
- MBBI = mergePairedInsns(MBBI, Paired, Flags);
- // Collect liveness info for instructions between Prev and the new position
- // MBBI.
- for (auto I = std::next(Prev); I != MBBI; I++)
- updateDefinedRegisters(*I, DefinedInBB, TRI);
+ // Get the needed alignments to check them if
+ // ldp-aligned-only/stp-aligned-only features are opted.
+ uint64_t MemAlignment = MemOp->getAlign().value();
+ uint64_t TypeAlignment =
+ Align(MemOp->getSize().getValue().getKnownMinValue()).value();
- return true;
+ if (MemAlignment < 2 * TypeAlignment) {
+ NumFailedAlignmentCheck++;
+ return false;
+ }
}
- return false;
+
+ ++NumPairCreated;
+ if (TII->hasUnscaledLdStOffset(MI))
+ ++NumUnscaledPairCreated;
+
+ MBBI = mergePairedInsns(MBBI, Paired, Flags);
+ // Collect liveness info for instructions between Prev and the new position
+ // MBBI.
+ for (auto I = std::next(Prev); I != MBBI; I++)
+ updateDefinedRegisters(*I, DefinedInBB, TRI);
+
+ return true;
}
bool AArch64LoadStoreOpt::tryToMergeLdStUpdate
More information about the llvm-commits
mailing list