diff options
| author | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:51:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2007-01-15 06:51:56 +0000 |
| commit | a4beeef76c0d91242bc1c555d5794f243bccb0e2 (patch) | |
| tree | 44b68efac539392aac692a8c0b213a55620aec71 /llvm | |
| parent | 8938a7c93011e02d9bd767b88c091e7700f82834 (diff) | |
| download | bcm5719-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')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 18 |
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 |

