summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorHans Wennborg <hans@chromium.org>2020-02-12 15:27:11 +0100
committerHans Wennborg <hans@chromium.org>2020-02-12 15:29:31 +0100
commitb3cf70427eb1e97d9b89ba6e9298c280c8a32c74 (patch)
treeb8e8ac4a93245446326480a80cb8262358d7b1b2 /llvm/lib/CodeGen
parent6f692404a30d7f58b20d40f7a6ceaf826320b145 (diff)
downloadbcm5719-llvm-b3cf70427eb1e97d9b89ba6e9298c280c8a32c74.tar.gz
bcm5719-llvm-b3cf70427eb1e97d9b89ba6e9298c280c8a32c74.zip
[CodeGen] Fix the computation of the alignment of split stores.
By Clement Courbet! Backported from rG15488ff24b4a
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 003db39fe5f..7d77664fbf6 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6857,12 +6857,20 @@ static bool splitMergedValStore(StoreInst &SI, const DataLayout &DL,
Value *Addr = Builder.CreateBitCast(
SI.getOperand(1),
SplitStoreType->getPointerTo(SI.getPointerAddressSpace()));
- if ((IsLE && Upper) || (!IsLE && !Upper))
+ const bool IsOffsetStore = (IsLE && Upper) || (!IsLE && !Upper);
+ if (IsOffsetStore)
Addr = Builder.CreateGEP(
SplitStoreType, Addr,
ConstantInt::get(Type::getInt32Ty(SI.getContext()), 1));
+ MaybeAlign Alignment(SI.getAlignment());
+ if (IsOffsetStore && Alignment) {
+ // When splitting the store in half, naturally one half will retain the
+ // alignment of the original wider store, regardless of whether it was
+ // over-aligned or not, while the other will require adjustment.
+ Alignment = commonAlignment(Alignment, HalfValBitSize / 8);
+ }
Builder.CreateAlignedStore(
- V, Addr, Upper ? SI.getAlignment() / 2 : SI.getAlignment());
+ V, Addr, Alignment.hasValue() ? Alignment.getValue().value() : 0);
};
CreateSplitStore(LValue, false);
OpenPOWER on IntegriCloud