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 | 62f254df04a78bf93ac9fa5859a9e7275867e853 (patch) | |
tree | cc46311c144626db6028d9ec58b36dcaa1fe76c1 | |
parent | 598fbf756fc1309d63e649b2ac27fa4d682519a1 (diff) |
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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23320 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 67dca06a42..67144b93cf 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/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)) || |