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

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



Changes in directory llvm/lib/Transforms/Scalar:

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

Implement a trivial form of store->load forwarding where the store and the
load are exactly consequtive.  This is picked up by other passes, but this
triggers thousands of times in fortran programs that use static locals
(and is thus a compile-time speedup).


---
Diffs of the changes:  (+9 -0)

 InstructionCombining.cpp |    9 +++++++++
 1 files changed, 9 insertions(+)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.365 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.366
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.365	Mon Aug  8 14:11:57 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Mon Sep 12 17:00:15 2005
@@ -4925,6 +4925,15 @@
 
   // 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 (StoreInst *SI = dyn_cast<StoreInst>(BBI))
+      if (SI->getOperand(1) == LI.getOperand(0))
+        return ReplaceInstUsesWith(LI, SI->getOperand(0));
+  }
 
   if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(Op))
     if (isa<ConstantPointerNull>(GEPI->getOperand(0)) ||






More information about the llvm-commits mailing list