[llvm-commits] [llvm] r127539 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
Jin-Gu Kang
jaykang10 at imrc.kist.re.kr
Sat Mar 12 04:18:44 PST 2011
Author: jaykang10
Date: Sat Mar 12 06:18:44 2011
New Revision: 127539
URL: http://llvm.org/viewvc/llvm-project?rev=127539&view=rev
Log:
This patch removes some of useless instructions generated by bitfield access.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp?rev=127539&r1=127538&r2=127539&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Sat Mar 12 06:18:44 2011
@@ -429,9 +429,19 @@
// 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.
More information about the llvm-commits
mailing list