[llvm-commits] [llvm] r45398 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Chris Lattner sabre at nondot.org
Fri Dec 28 22:26:16 PST 2007


Author: lattner
Date: Sat Dec 29 00:26:16 2007
New Revision: 45398

URL: http://llvm.org/viewvc/llvm-project?rev=45398&view=rev
Log:
Delete a store whose input is a load from the same pointer:
  x = load p
  store x -> p

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=45398&r1=45397&r2=45398&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Dec 29 00:26:16 2007
@@ -4223,7 +4223,7 @@
   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 @@
       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();
 }
 





More information about the llvm-commits mailing list