Skip to content

Revert "[AArch64] Verify ldp/stp alignment stricter" #84096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ STATISTIC(NumUnscaledPairCreated,
"Number of load/store from unscaled generated");
STATISTIC(NumZeroStoresPromoted, "Number of narrow zero stores promoted");
STATISTIC(NumLoadsFromStoresPromoted, "Number of loads from stores promoted");
STATISTIC(NumFailedAlignmentCheck, "Number of load/store pair transformation "
"not passed the alignment check");

DEBUG_COUNTER(RegRenamingCounter, DEBUG_TYPE "-reg-renaming",
"Controls which pairs are considered for renaming");
Expand Down Expand Up @@ -2339,6 +2337,9 @@ bool AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
MachineBasicBlock::iterator Paired =
findMatchingInsn(MBBI, Flags, LdStLimit, /* FindNarrowMerge = */ false);
if (Paired != E) {
++NumPairCreated;
if (TII->hasUnscaledLdStOffset(MI))
++NumUnscaledPairCreated;
// 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);
Expand All @@ -2348,38 +2349,31 @@ bool AArch64LoadStoreOpt::tryToPairLdStInst(MachineBasicBlock::iterator &MBBI) {
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 ? MemOp->getAlign().value() : -1;
uint64_t TypeAlignment = MemOp ? Align(MemOp->getSize()).value() : -1;

// 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()).value();
// If a load arrives and ldp-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() && MemOp &&
MemAlignment < 2 * TypeAlignment)
return false;

if (MemAlignment < 2 * TypeAlignment) {
NumFailedAlignmentCheck++;
return false;
}
}
// If a store arrives and 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.mayStore() && Subtarget->hasStpAlignedOnly() && MemOp &&
MemAlignment < 2 * TypeAlignment)
return false;

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);

++NumPairCreated;
if (TII->hasUnscaledLdStOffset(MI))
++NumUnscaledPairCreated;

return true;
}
return false;
Expand Down
56 changes: 0 additions & 56 deletions llvm/test/CodeGen/AArch64/ldp-stp-unknown-size.mir

This file was deleted.