aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorAlex Richardson <alexrichardson@google.com>2022-09-20 13:19:16 +0000
committerAlex Richardson <alexrichardson@google.com>2022-11-17 11:59:35 +0000
commit754d25844a7e5793b1b6523ce223061dba7da7c1 (patch)
treef1fa30b3d2d599284790962cf13b0a5fbf2b31a4 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent89a86ed9818ed1f13b02d6dc3cdae136a773a4dd (diff)
downloadllvm-754d25844a7e5793b1b6523ce223061dba7da7c1.zip
llvm-754d25844a7e5793b1b6523ce223061dba7da7c1.tar.gz
llvm-754d25844a7e5793b1b6523ce223061dba7da7c1.tar.bz2
[CGP] Update MemIntrinsic alignment if possible
Previously it was only being done if shouldAlignPointerArgs() returned true, which right now is only true for ARM targets. Updating the argument alignment attributes of memcpy/memset intrinsics if the underlying object has larger alignment can be beneficial even when CGP didn't increase alignment (as can be seen from the test changes), so invert the loop and if condition. Differential Revision: https://reviews.llvm.org/D134281
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index cf2b32c..355f5a2 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -2252,19 +2252,19 @@ bool CodeGenPrepare::optimizeCallInst(CallInst *CI, ModifyDT &ModifiedDT) {
DL->getTypeAllocSize(GV->getValueType()) >= MinSize + Offset2)
GV->setAlignment(PrefAlign);
}
- // If this is a memcpy (or similar) then we may be able to improve the
- // alignment
- if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(CI)) {
- Align DestAlign = getKnownAlignment(MI->getDest(), *DL);
- MaybeAlign MIDestAlign = MI->getDestAlign();
- if (!MIDestAlign || DestAlign > *MIDestAlign)
- MI->setDestAlignment(DestAlign);
- if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
- MaybeAlign MTISrcAlign = MTI->getSourceAlign();
- Align SrcAlign = getKnownAlignment(MTI->getSource(), *DL);
- if (!MTISrcAlign || SrcAlign > *MTISrcAlign)
- MTI->setSourceAlignment(SrcAlign);
- }
+ }
+ // If this is a memcpy (or similar) then we may be able to improve the
+ // alignment.
+ if (MemIntrinsic *MI = dyn_cast<MemIntrinsic>(CI)) {
+ Align DestAlign = getKnownAlignment(MI->getDest(), *DL);
+ MaybeAlign MIDestAlign = MI->getDestAlign();
+ if (!MIDestAlign || DestAlign > *MIDestAlign)
+ MI->setDestAlignment(DestAlign);
+ if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
+ MaybeAlign MTISrcAlign = MTI->getSourceAlign();
+ Align SrcAlign = getKnownAlignment(MTI->getSource(), *DL);
+ if (!MTISrcAlign || SrcAlign > *MTISrcAlign)
+ MTI->setSourceAlignment(SrcAlign);
}
}