1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

clean up some corner cases

llvm-svn: 23692
This commit is contained in:
Chris Lattner 2005-10-10 23:00:08 +00:00
parent 5308a566ba
commit 1441e42e56

View File

@ -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();