summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2014-09-27 17:02:54 +0000
committerJames Molloy <james.molloy@arm.com>2014-09-27 17:02:54 +0000
commit463db9a77cb2521ffd0fea8c53afd3fa0e56fa2d (patch)
tree7b95fd20d82a06e2bf83629eed8764f17e7b8805 /llvm/lib/CodeGen/SelectionDAG
parentcacde7df6dc9d8c94401b7e26714dbd7383bcc15 (diff)
downloadbcm5719-llvm-463db9a77cb2521ffd0fea8c53afd3fa0e56fa2d.tar.gz
bcm5719-llvm-463db9a77cb2521ffd0fea8c53afd3fa0e56fa2d.zip
[AArch64] Redundant store instructions should be removed as dead code
If there is a store followed by a store with the same value to the same location, then the store is dead/noop. It can be removed. This problem is found in spec2006-197.parser. For example, stur w10, [x11, #-4] stur w10, [x11, #-4] Then one of the two stur instructions can be removed. Patch by David Xu! llvm-svn: 218569
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 34a0e04bc05..2b65cce970c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -9858,6 +9858,17 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {
}
}
+ // If this is a store followed by a store with the same value to the same
+ // location, then the store is dead/noop.
+ if (StoreSDNode *ST1 = dyn_cast<StoreSDNode>(Chain)) {
+ if (ST1->getBasePtr() == Ptr && ST->getMemoryVT() == ST1->getMemoryVT() &&
+ ST1->getValue() == Value && ST->isUnindexed() && !ST->isVolatile() &&
+ ST1->isUnindexed() && !ST1->isVolatile()) {
+ // The store is dead, remove it.
+ return Chain;
+ }
+ }
+
// If this is an FP_ROUND or TRUNC followed by a store, fold this into a
// truncating store. We can do this even if this is already a truncstore.
if ((Value.getOpcode() == ISD::FP_ROUND || Value.getOpcode() == ISD::TRUNCATE)
OpenPOWER on IntegriCloud