summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJames Molloy <jmolloy@google.com>2019-08-31 10:46:16 +0000
committerJames Molloy <jmolloy@google.com>2019-08-31 10:46:16 +0000
commite62c509cd4c0701ab3b951269cef7da2ca803780 (patch)
treebcbc1dd7943cfbe97520633e25e375e8f0e3130d /llvm/lib/CodeGen
parentac5821395bb8f019032ddf9f2eb4746ceedaf1c3 (diff)
downloadbcm5719-llvm-e62c509cd4c0701ab3b951269cef7da2ca803780.tar.gz
bcm5719-llvm-e62c509cd4c0701ab3b951269cef7da2ca803780.zip
[DAGCombiner] Don't create illegal narrow stores
Narrowing stores when the target doesn't support the narrow version forces the target to expand into a load-modify-store sequence, which is highly suboptimal. The information narrowing throws away (legality of the inverse transform) is hard to re-analyze. If the target doesn't support a store of the narrow type, don't narrow even in pre-legalize mode. No test as this is DAGCombiner and depends on target bits. llvm-svn: 370576
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index ac0d0884d7c..7c73212c294 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14737,10 +14737,15 @@ ShrinkLoadReplaceStoreWithStore(const std::pair<unsigned, unsigned> &MaskInfo,
// Check that it is legal on the target to do this. It is legal if the new
// VT we're shrinking to (i8/i16/i32) is legal or we're still before type
- // legalization.
- MVT VT = MVT::getIntegerVT(NumBytes*8);
+ // legalization (and the target doesn't explicitly think this is a bad idea).
+ MVT VT = MVT::getIntegerVT(NumBytes * 8);
+ const TargetLowering &TLI = DAG.getTargetLoweringInfo();
if (!DC->isTypeLegal(VT))
return SDValue();
+ if (St->getMemOperand() &&
+ !TLI.allowsMemoryAccess(*DAG.getContext(), DAG.getDataLayout(), VT,
+ *St->getMemOperand()))
+ return SDValue();
// Okay, we can do this! Replace the 'St' store with a store of IVal that is
// shifted by ByteShift and truncated down to NumBytes.
OpenPOWER on IntegriCloud