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

Chris Lattner lattner at cs.uiuc.edu
Mon Sep 12 15:21:15 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.366 -> 1.367
---
Log message:

Another load-peephole optimization: do gcse when two loads are next to 
each other.  This implements InstCombine/load.ll:test9


---
Diffs of the changes:  (+5 -2)

 InstructionCombining.cpp |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.366 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.367
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.366	Mon Sep 12 17:00:15 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Sep 12 17:21:03 2005
@@ -4926,13 +4926,16 @@
   // None of the following transforms are legal for volatile loads.
   if (LI.isVolatile()) return 0;
   
-  // If the instruction immediately before this is a store to the same address,
-  // do a simple form of store->load forwarding.
   if (&LI.getParent()->front() != &LI) {
     BasicBlock::iterator BBI = &LI; --BBI;
+    // If the instruction immediately before this is a store to the same
+    // address, do a simple form of store->load forwarding.
     if (StoreInst *SI = dyn_cast<StoreInst>(BBI))
       if (SI->getOperand(1) == LI.getOperand(0))
         return ReplaceInstUsesWith(LI, SI->getOperand(0));
+    if (LoadInst *LIB = dyn_cast<LoadInst>(BBI))
+      if (LIB->getOperand(0) == LI.getOperand(0))
+        return ReplaceInstUsesWith(LI, LIB);
   }
 
   if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(Op))






More information about the llvm-commits mailing list