summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-26 19:19:20 +0000
committerChris Lattner <sabre@nondot.org>2006-05-26 19:19:20 +0000
commitdab43b2b0e7a832b2eb70715645fd8604bbb9746 (patch)
tree04fd0844193ace16e08121b32e9de50eb74473ed /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent158dd8aca866fcb03ef6e57d8f4bc6335bd303da (diff)
downloadbcm5719-llvm-dab43b2b0e7a832b2eb70715645fd8604bbb9746.tar.gz
bcm5719-llvm-dab43b2b0e7a832b2eb70715645fd8604bbb9746.zip
Implement Transforms/InstCombine/store.ll:test2.
llvm-svn: 28503
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 1264e55497d..30a1de23aa4 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -6833,8 +6833,22 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
break;
}
+ // If this is a load, we have to stop. However, if the loaded value is from
+ // the pointer we're loading and is producing the pointer we're storing,
+ // then *this* store is dead (X = load P; store X -> P).
+ if (LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
+ if (LI == Val && LI->getOperand(0) == Ptr) {
+ EraseInstFromFunction(SI);
+ ++NumCombined;
+ return 0;
+ }
+ // Otherwise, this is a load from some other location. Stores before it
+ // may not be dead.
+ break;
+ }
+
// Don't skip over loads or things that can modify memory.
- if (BBI->mayWriteToMemory() || isa<LoadInst>(BBI))
+ if (BBI->mayWriteToMemory())
break;
}
OpenPOWER on IntegriCloud