summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-29 06:26:16 +0000
committerChris Lattner <sabre@nondot.org>2007-12-29 06:26:16 +0000
commit3f9c6a726083b38fd04afdb36e6716ee5dc4ed67 (patch)
tree68177e227ce9e6f8560c0d77f3ef4dcadcd3cb55
parent62ba67c0f7745754ed65db239b7ef1c40c2384a2 (diff)
downloadbcm5719-llvm-3f9c6a726083b38fd04afdb36e6716ee5dc4ed67.tar.gz
bcm5719-llvm-3f9c6a726083b38fd04afdb36e6716ee5dc4ed67.zip
Delete a store whose input is a load from the same pointer:
x = load p store x -> p llvm-svn: 45398
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 6eaf7ae7f40..242fffd1802 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4223,7 +4223,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
if (CombineToPreIndexedLoadStore(N) || CombineToPostIndexedLoadStore(N))
return SDOperand(N, 0);
- // FIXME: is there such a think as a truncating indexed store?
+ // FIXME: is there such a thing as a truncating indexed store?
if (ST->isTruncatingStore() && ST->getAddressingMode() == ISD::UNINDEXED &&
MVT::isInteger(Value.getValueType())) {
// See if we can simplify the input to this truncstore with knowledge that
@@ -4243,6 +4243,17 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
return SDOperand(N, 0);
}
+ // If this is a load followed by a store to the same location, then the store
+ // is dead/noop.
+ if (LoadSDNode *Ld = dyn_cast<LoadSDNode>(Value)) {
+ if (Chain.Val == Ld && Ld->getBasePtr() == Ptr &&
+ ST->getAddressingMode() == ISD::UNINDEXED &&
+ ST->getStoredVT() == Ld->getLoadedVT()) {
+ // The store is dead, remove it.
+ return Chain;
+ }
+ }
+
return SDOperand();
}
OpenPOWER on IntegriCloud