[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri May 26 12:19:33 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.487 -> 1.488
---
Log message:

Implement Transforms/InstCombine/store.ll:test2.



---
Diffs of the changes:  (+15 -1)

 InstructionCombining.cpp |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.487 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.488
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.487	Thu May 25 19:29:06 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Fri May 26 14:19:20 2006
@@ -6833,8 +6833,22 @@
       break;
     }
     
+    // If this is a load, we have to stop.  However, if the loaded value is from
+    // the pointer we're loading and is producing the pointer we're storing,
+    // then *this* store is dead (X = load P; store X -> P).
+    if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
+      if (LI == Val && LI->getOperand(0) == Ptr) {
+        EraseInstFromFunction(SI);
+        ++NumCombined;
+        return 0;
+      }
+      // Otherwise, this is a load from some other location.  Stores before it
+      // may not be dead.
+      break;
+    }
+    
     // Don't skip over loads or things that can modify memory.
-    if (BBI->mayWriteToMemory() || isa<LoadInst>(BBI))
+    if (BBI->mayWriteToMemory())
       break;
   }
   






More information about the llvm-commits mailing list