summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-07-06 14:05:09 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-07-06 14:05:09 +0000
commitc7332b279664982a78038a924b13dbe210ca90e1 (patch)
treecda60b59bb1f9e5a494ddbe25ba6ae71eaa355ef /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parentdab4db53727cbdd7a693a4a0c646307f2c7b497a (diff)
downloadbcm5719-llvm-c7332b279664982a78038a924b13dbe210ca90e1.tar.gz
bcm5719-llvm-c7332b279664982a78038a924b13dbe210ca90e1.zip
DAGCombiner: Don't drop extension behavior when shrinking a load when unsafe.
ReduceLoadWidth unconditionally drops extensions from loads. Limit it to the case when all of the bits the extension would otherwise produce are dropped by the shrink. It would be possible to shrink the load in more cases by merging the extensions, but this isn't trivial and a very rare case. I left a TODO for that case. Fixes PR16551. llvm-svn: 185755
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 1688fc495ad..276a5b929b0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -5220,6 +5220,13 @@ SDValue DAGCombiner::ReduceLoadWidth(SDNode *N) {
if (LN0->getNumValues() > 2)
return SDValue();
+ // If the load that we're shrinking is an extload and we're not just
+ // discarding the extension we can't simply shrink the load. Bail.
+ // TODO: It would be possible to merge the extensions in some cases.
+ if (LN0->getExtensionType() != ISD::NON_EXTLOAD &&
+ LN0->getMemoryVT().getSizeInBits() < ExtVT.getSizeInBits() + ShAmt)
+ return SDValue();
+
EVT PtrType = N0.getOperand(1).getValueType();
if (PtrType == MVT::Untyped || PtrType.isExtended())
OpenPOWER on IntegriCloud