diff options
author | Chris Lattner <sabre@nondot.org> | 2005-09-12 22:21:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-09-12 22:21:03 +0000 |
commit | 9c1f0fd8de9b1c8ef1429110a3e3b878920401ef (patch) | |
tree | 7a76fa8a4bcf2da39a7ac0843556b54f05456f4d /lib/Transforms | |
parent | 128a0032a267c38d5df6b6f5578fb9f2b0f2b159 (diff) |
Another load-peephole optimization: do gcse when two loads are next to
each other. This implements InstCombine/load.ll:test9
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23322 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 67144b93cf..b508977cf3 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -4926,13 +4926,16 @@ 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 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)) |