diff options
author | Chris Lattner <sabre@nondot.org> | 2007-12-29 06:26:16 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-12-29 06:26:16 +0000 |
commit | 3c87285af63bc6d9b93f8eefe46ce9fea063d66c (patch) | |
tree | f95149728d07011938be8cb1c67d09a725d027c4 /lib/CodeGen | |
parent | 7ede51b964a2a7d2ca23c25bde9b8123efab401c (diff) |
Delete a store whose input is a load from the same pointer:
x = load p
store x -> p
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45398 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 6eaf7ae7f4..242fffd180 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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(); } |