delete stores to allocas with one use. This is a trivial form of DSE which
often kicks in for ?: expressions. llvm-svn: 33231
This commit is contained in:
parent
8938a7c930
commit
a4beeef76c
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue