summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2011-11-28 20:42:56 +0000
committerEvan Cheng <evan.cheng@apple.com>2011-11-28 20:42:56 +0000
commita4b6404cf0ad8fae26188d780d583ef499f99b3b (patch)
treef12f1c5f5729087f46c2c1c3c2f4866571a98e4b /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentaa93ceb164f92666707e859961b413d924aabbf7 (diff)
downloadbcm5719-llvm-a4b6404cf0ad8fae26188d780d583ef499f99b3b.tar.gz
bcm5719-llvm-a4b6404cf0ad8fae26188d780d583ef499f99b3b.zip
DAG combine should not increase alignment of loads / stores with alignment less
than ABI alignment. These are loads / stores from / to "packed" data structures. Their alignments are intentionally under-specified. rdar://10301431 llvm-svn: 145273
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp38
1 files changed, 26 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d8208a44338..2c4886a3c83 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -6206,13 +6206,20 @@ SDValue DAGCombiner::visitLOAD(SDNode *N) {
// Try to infer better alignment information than the load already has.
if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) {
- if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
- if (Align > LD->getAlignment())
- return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(),
- LD->getValueType(0),
- Chain, Ptr, LD->getPointerInfo(),
- LD->getMemoryVT(),
- LD->isVolatile(), LD->isNonTemporal(), Align);
+ unsigned ABIAlign = TLI.getTargetData()->
+ getABITypeAlignment(LD->getMemoryVT().getTypeForEVT(*DAG.getContext()));
+ unsigned LDAlign = LD->getAlignment();
+ // Do not touch loads with explicit alignments that are smaller than ABI
+ // alignment to avoid breaking loads from "packed" types.
+ if (!LDAlign || LDAlign >= ABIAlign) {
+ if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
+ if (Align > LDAlign)
+ return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(),
+ LD->getValueType(0),
+ Chain, Ptr, LD->getPointerInfo(),
+ LD->getMemoryVT(),
+ LD->isVolatile(), LD->isNonTemporal(), Align);
+ }
}
}
@@ -6669,11 +6676,18 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
// Try to infer better alignment information than the store already has.
if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) {
- if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
- if (Align > ST->getAlignment())
- return DAG.getTruncStore(Chain, N->getDebugLoc(), Value,
- Ptr, ST->getPointerInfo(), ST->getMemoryVT(),
- ST->isVolatile(), ST->isNonTemporal(), Align);
+ unsigned ABIAlign = TLI.getTargetData()->
+ getABITypeAlignment(ST->getMemoryVT().getTypeForEVT(*DAG.getContext()));
+ unsigned STAlign = ST->getAlignment();
+ // Do not touch stores with explicit alignments that are smaller than ABI
+ // alignment to avoid breaking stores from "packed" types.
+ if (!STAlign || STAlign >= ABIAlign) {
+ if (unsigned Align = DAG.InferPtrAlignment(Ptr)) {
+ if (Align > STAlign)
+ return DAG.getTruncStore(Chain, N->getDebugLoc(), Value,
+ Ptr, ST->getPointerInfo(), ST->getMemoryVT(),
+ ST->isVolatile(), ST->isNonTemporal(),Align);
+ }
}
}
OpenPOWER on IntegriCloud