Skip to content

Commit 6f11c95

Browse files
authored
Revert "[AArch64] Verify ldp/stp alignment stricter" (#84096)
Reverts #83948 This broke the ASan buildbot: https://lab.llvm.org/buildbot/#/builders/168/builds/19054/steps/10/logs/stdio
1 parent d6c52c1 commit 6f11c95

File tree

2 files changed

+19
-81
lines changed

2 files changed

+19
-81
lines changed

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ STATISTIC(NumUnscaledPairCreated,
6262
"Number of load/store from unscaled generated");
6363
STATISTIC(NumZeroStoresPromoted, "Number of narrow zero stores promoted");
6464
STATISTIC(NumLoadsFromStoresPromoted, "Number of loads from stores promoted");
65-
STATISTIC(NumFailedAlignmentCheck, "Number of load/store pair transformation "
66-
"not passed the alignment check");
6765

6866
DEBUG_COUNTER(RegRenamingCounter, DEBUG_TYPE "-reg-renaming",
6967
"Controls which pairs are considered for renaming");
@@ -2339,6 +2337,9 @@ bool AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
23392337
MachineBasicBlock::iterator Paired =
23402338
findMatchingInsn(MBBI, Flags, LdStLimit, /* FindNarrowMerge = */ false);
23412339
if (Paired != E) {
2340+
++NumPairCreated;
2341+
if (TII->hasUnscaledLdStOffset(MI))
2342+
++NumUnscaledPairCreated;
23422343
// Keeping the iterator straight is a pain, so we let the merge routine tell
23432344
// us what the next instruction is after it's done mucking about.
23442345
auto Prev = std::prev(MBBI);
@@ -2348,38 +2349,31 @@ bool AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
23482349
MachineMemOperand *MemOp =
23492350
MI.memoperands_empty() ? nullptr : MI.memoperands().front();
23502351

2351-
// If a load/store arrives and ldp/stp-aligned-only feature is opted, check
2352-
// that the alignment of the source pointer is at least double the alignment
2353-
// of the type.
2354-
if ((MI.mayLoad() && Subtarget->hasLdpAlignedOnly()) ||
2355-
(MI.mayStore() && Subtarget->hasStpAlignedOnly())) {
2356-
// If there is no size/align information, cancel the transformation.
2357-
if (!MemOp || !MemOp->getMemoryType().isValid()) {
2358-
NumFailedAlignmentCheck++;
2359-
return false;
2360-
}
2352+
// Get the needed alignments to check them if
2353+
// ldp-aligned-only/stp-aligned-only features are opted.
2354+
uint64_t MemAlignment = MemOp ? MemOp->getAlign().value() : -1;
2355+
uint64_t TypeAlignment = MemOp ? Align(MemOp->getSize()).value() : -1;
23612356

2362-
// Get the needed alignments to check them if
2363-
// ldp-aligned-only/stp-aligned-only features are opted.
2364-
uint64_t MemAlignment = MemOp->getAlign().value();
2365-
uint64_t TypeAlignment = Align(MemOp->getSize()).value();
2357+
// If a load arrives and ldp-aligned-only feature is opted, check that the
2358+
// alignment of the source pointer is at least double the alignment of the
2359+
// type.
2360+
if (MI.mayLoad() && Subtarget->hasLdpAlignedOnly() && MemOp &&
2361+
MemAlignment < 2 * TypeAlignment)
2362+
return false;
23662363

2367-
if (MemAlignment < 2 * TypeAlignment) {
2368-
NumFailedAlignmentCheck++;
2369-
return false;
2370-
}
2371-
}
2364+
// If a store arrives and stp-aligned-only feature is opted, check that the
2365+
// alignment of the source pointer is at least double the alignment of the
2366+
// type.
2367+
if (MI.mayStore() && Subtarget->hasStpAlignedOnly() && MemOp &&
2368+
MemAlignment < 2 * TypeAlignment)
2369+
return false;
23722370

23732371
MBBI = mergePairedInsns(MBBI, Paired, Flags);
23742372
// Collect liveness info for instructions between Prev and the new position
23752373
// MBBI.
23762374
for (auto I = std::next(Prev); I != MBBI; I++)
23772375
updateDefinedRegisters(*I, DefinedInBB, TRI);
23782376

2379-
++NumPairCreated;
2380-
if (TII->hasUnscaledLdStOffset(MI))
2381-
++NumUnscaledPairCreated;
2382-
23832377
return true;
23842378
}
23852379
return false;

llvm/test/CodeGen/AArch64/ldp-stp-unknown-size.mir

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)