[PATCH] D77538: [Alignment][NFC] Assume AlignmentFromAssumptions::getNewAlignment is always set.
Guillaume Chatelet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 6 04:17:52 PDT 2020
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
In D77454 <https://reviews.llvm.org/D77454> we explain that `LoadInst` and `StoreInst` always have their alignment defined.
This allows to work backward here and to infer that `getNewAlignment` does not need to return `0` in case of failure.
Returning `1` also works since it needs to be greater than the Load/Store alignment which is a least `1`.
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77538
Files:
llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
Index: llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -321,29 +321,28 @@
while (!WorkList.empty()) {
Instruction *J = WorkList.pop_back_val();
-
if (LoadInst *LI = dyn_cast<LoadInst>(J)) {
- unsigned NewAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
- LI->getPointerOperand(), SE);
+ Align NewAlignment = assumeAligned(getNewAlignment(
+ AASCEV, AlignSCEV, OffSCEV, LI->getPointerOperand(), SE));
- if (NewAlignment > LI->getAlignment()) {
- LI->setAlignment(MaybeAlign(NewAlignment));
+ if (NewAlignment > *LI->getAlign()) {
+ LI->setAlignment(NewAlignment);
++NumLoadAlignChanged;
}
} else if (StoreInst *SI = dyn_cast<StoreInst>(J)) {
- unsigned NewAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
- SI->getPointerOperand(), SE);
+ Align NewAlignment = assumeAligned(getNewAlignment(
+ AASCEV, AlignSCEV, OffSCEV, SI->getPointerOperand(), SE));
- if (NewAlignment > SI->getAlignment()) {
- SI->setAlignment(MaybeAlign(NewAlignment));
+ if (NewAlignment > *SI->getAlign()) {
+ SI->setAlignment(NewAlignment);
++NumStoreAlignChanged;
}
} else if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(J)) {
- unsigned NewDestAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
- MI->getDest(), SE);
+ Align NewDestAlignment = assumeAligned(
+ getNewAlignment(AASCEV, AlignSCEV, OffSCEV, MI->getDest(), SE));
LLVM_DEBUG(dbgs() << "\tmem inst: " << NewDestAlignment << "\n";);
- if (NewDestAlignment > MI->getDestAlignment()) {
+ if (NewDestAlignment > *MI->getDestAlign()) {
MI->setDestAlignment(NewDestAlignment);
++NumMemIntAlignChanged;
}
@@ -351,12 +350,12 @@
// For memory transfers, there is also a source alignment that
// can be set.
if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
- unsigned NewSrcAlignment = getNewAlignment(AASCEV, AlignSCEV, OffSCEV,
- MTI->getSource(), SE);
+ Align NewSrcAlignment = assumeAligned(
+ getNewAlignment(AASCEV, AlignSCEV, OffSCEV, MTI->getSource(), SE));
LLVM_DEBUG(dbgs() << "\tmem trans: " << NewSrcAlignment << "\n";);
- if (NewSrcAlignment > MTI->getSourceAlignment()) {
+ if (NewSrcAlignment > *MTI->getSourceAlign()) {
MTI->setSourceAlignment(NewSrcAlignment);
++NumMemIntAlignChanged;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77538.255280.patch
Type: text/x-patch
Size: 2702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200406/06bd8bf0/attachment.bin>
More information about the llvm-commits
mailing list