1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00

Delete a store whose input is a load from the same pointer:

x = load p
  store x -> p

llvm-svn: 45398
This commit is contained in:
Chris Lattner 2007-12-29 06:26:16 +00:00
parent ac72965e02
commit 7cb2de8e48

View File

@ -4223,7 +4223,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
if (CombineToPreIndexedLoadStore(N) || CombineToPostIndexedLoadStore(N)) if (CombineToPreIndexedLoadStore(N) || CombineToPostIndexedLoadStore(N))
return SDOperand(N, 0); 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 && if (ST->isTruncatingStore() && ST->getAddressingMode() == ISD::UNINDEXED &&
MVT::isInteger(Value.getValueType())) { MVT::isInteger(Value.getValueType())) {
// See if we can simplify the input to this truncstore with knowledge that // 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); 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(); return SDOperand();
} }