Skip to content

Commit

Permalink
Revert "[AArch64] Verify ldp/stp alignment stricter" (#84096)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmayer committed Mar 5, 2024
1 parent d6c52c1 commit 6f11c95
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 81 deletions.
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.

0 comments on commit 6f11c95

Please sign in to comment.