summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-15 06:51:56 +0000
committerChris Lattner <sabre@nondot.org>2007-01-15 06:51:56 +0000
commita4beeef76c0d91242bc1c555d5794f243bccb0e2 (patch)
tree44b68efac539392aac692a8c0b213a55620aec71 /llvm/lib
parent8938a7c93011e02d9bd767b88c091e7700f82834 (diff)
downloadbcm5719-llvm-a4beeef76c0d91242bc1c555d5794f243bccb0e2.tar.gz
bcm5719-llvm-a4beeef76c0d91242bc1c555d5794f243bccb0e2.zip
delete stores to allocas with one use. This is a trivial form of DSE which
often kicks in for ?: expressions. llvm-svn: 33231
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index f961ac25e95..dc071380435 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -8237,6 +8237,24 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
++NumCombined;
return 0;
}
+
+ // If the RHS is an alloca with a single use, zapify the store, making the
+ // alloca dead.
+ if (Ptr->hasOneUse()) {
+ if (isa<AllocaInst>(Ptr)) {
+ EraseInstFromFunction(SI);
+ ++NumCombined;
+ return 0;
+ }
+
+ if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr))
+ if (isa<AllocaInst>(GEP->getOperand(0)) &&
+ GEP->getOperand(0)->hasOneUse()) {
+ EraseInstFromFunction(SI);
+ ++NumCombined;
+ return 0;
+ }
+ }
// Do really simple DSE, to catch cases where there are several consequtive
// stores to the same location, separated by a few arithmetic operations. This
OpenPOWER on IntegriCloud