summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-09-12 22:21:03 +0000
committerChris Lattner <sabre@nondot.org>2005-09-12 22:21:03 +0000
commite0bfdf14855a6e368a0a125e278b52b42783eda1 (patch)
tree3321fca0b4c1c5877960af36f286a8dff54e829e /llvm/lib/Transforms
parent20c1cc074190f38bdbee941cba783deaa6b55378 (diff)
downloadbcm5719-llvm-e0bfdf14855a6e368a0a125e278b52b42783eda1.tar.gz
bcm5719-llvm-e0bfdf14855a6e368a0a125e278b52b42783eda1.zip
Another load-peephole optimization: do gcse when two loads are next to
each other. This implements InstCombine/load.ll:test9 llvm-svn: 23322
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 67144b93cfe..b508977cf36 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/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))
OpenPOWER on IntegriCloud