diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-10 23:00:08 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-10 23:00:08 +0000 |
commit | 04ecf6d65fb5c8703eff8a3dcd5a8208e91318fe (patch) | |
tree | a3667d0e3d660b6391aa2b09af1ba05a961f7f97 /lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | 87514ca04cb069310d29fd77e0501601c1e22c11 (diff) |
clean up some corner cases
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b58b8cace2..efeee071f0 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -1583,14 +1583,18 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) { SDOperand SrcValue = N->getOperand(3); // If this is a store that kills a previous store, remove the previous store. - if (Chain.getOpcode() == ISD::STORE && Chain.getOperand(2) == Ptr) { + if (Chain.getOpcode() == ISD::STORE && Chain.getOperand(2) == Ptr && + Chain.Val->hasOneUse() /* Avoid introducing DAG cycles */) { // Create a new store of Value that replaces both stores. SDNode *PrevStore = Chain.Val; + if (PrevStore->getOperand(1) == Value) // Same value multiply stored. + return Chain; SDOperand NewStore = DAG.getNode(ISD::STORE, MVT::Other, PrevStore->getOperand(0), Value, Ptr, SrcValue); + CombineTo(N, NewStore); // Nuke this store. CombineTo(PrevStore, NewStore); // Nuke the previous store. - return NewStore; // Replace this store with NewStore. + return SDOperand(N, 0); } return SDOperand(); |