diff options
| author | Jin-Gu Kang <jaykang10@imrc.kist.re.kr> | 2011-03-12 12:18:44 +0000 |
|---|---|---|
| committer | Jin-Gu Kang <jaykang10@imrc.kist.re.kr> | 2011-03-12 12:18:44 +0000 |
| commit | 2e939f7c3c4bac437a357d2fc7ce4849553c7402 (patch) | |
| tree | 9738d16ab5c0ad2226a07067ee1aaad1f97c9a97 /llvm/lib/Transforms/InstCombine | |
| parent | a862d95054ec99de14b31b320924157066994114 (diff) | |
| download | bcm5719-llvm-2e939f7c3c4bac437a357d2fc7ce4849553c7402.tar.gz bcm5719-llvm-2e939f7c3c4bac437a357d2fc7ce4849553c7402.zip | |
This patch removes some of useless instructions generated by bitfield access.
llvm-svn: 127539
Diffstat (limited to 'llvm/lib/Transforms/InstCombine')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 35c1d91d501..f233ca6af1d 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -429,9 +429,19 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) { // 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 && equivalentAddressValues(LI->getOperand(0), Ptr) && - !SI.isVolatile()) - return EraseInstFromFunction(SI); + if (equivalentAddressValues(LI->getOperand(0), Ptr) && + !SI.isVolatile()) { + if (LI == Val) + return EraseInstFromFunction(SI); + if (Ptr->hasNUses(2)) { + if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr)) { + if (isa<AllocaInst>(GEP->getOperand(0))) { + if (GEP->getOperand(0)->hasOneUse()) + return EraseInstFromFunction(SI); + } + } + } + } // Otherwise, this is a load from some other location. Stores before it // may not be dead. |

