diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-09-12 22:00:15 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-09-12 22:00:15 +0000 |
| commit | b990f7d8eda363d374f47cc1c9b904f1e9f7348e (patch) | |
| tree | 6e300142926eb446b8eef054e87f0440547cec1e /llvm/lib/Transforms | |
| parent | 4cd474ebbdaf7ab748f6c1bb9618de0d42f6d165 (diff) | |
| download | bcm5719-llvm-b990f7d8eda363d374f47cc1c9b904f1e9f7348e.tar.gz bcm5719-llvm-b990f7d8eda363d374f47cc1c9b904f1e9f7348e.zip | |
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).
llvm-svn: 23320
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 67dca06a420..67144b93cfe 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4925,6 +4925,15 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { // 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)) || |

