aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
diff options
context:
space:
mode:
authorJin-Gu Kang <jaykang10@imrc.kist.re.kr>2011-03-13 14:05:51 +0000
committerJin-Gu Kang <jaykang10@imrc.kist.re.kr>2011-03-13 14:05:51 +0000
commit198e97c4238079f6af0ffd675c2339dcc46b9d8e (patch)
tree4cedef437a92d3ebc71c22fb57ebda364798cb04 /lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
parent98f6ddc3c5f16e52f6d0bfd56258abc545093807 (diff)
Add comment as following:
load and store reference same memory location, the memory location is represented by getelementptr with two uses (load and store) and the getelementptr's base is alloca with single use. At this point, instructions from alloca to store can be removed. (this pattern is generated when bitfield is accessed.) For example, %u = alloca %struct.test, align 4 ; [#uses=1] %0 = getelementptr inbounds %struct.test* %u, i32 0, i32 0;[#uses=2] %1 = load i8* %0, align 4 ; [#uses=1] %2 = and i8 %1, -16 ; [#uses=1] %3 = or i8 %2, 5 ; [#uses=1] store i8 %3, i8* %0, align 4 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp')
-rw-r--r--lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index f233ca6af1..e5ff00fc1d 100644
--- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -433,6 +433,18 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {
!SI.isVolatile()) {
if (LI == Val)
return EraseInstFromFunction(SI);
+ // load and store reference same memory location, the memory location
+ // is represented by getelementptr with two uses (load and store) and
+ // the getelementptr's base is alloca with single use. At this point,
+ // instructions from alloca to store can be removed.
+ // (this pattern is generated when bitfield is accessed.)
+ // For example,
+ // %u = alloca %struct.test, align 4 ; [#uses=1]
+ // %0 = getelementptr inbounds %struct.test* %u, i32 0, i32 0;[#uses=2]
+ // %1 = load i8* %0, align 4 ; [#uses=1]
+ // %2 = and i8 %1, -16 ; [#uses=1]
+ // %3 = or i8 %2, 5 ; [#uses=1]
+ // store i8 %3, i8* %0, align 4
if (Ptr->hasNUses(2)) {
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
if (isa<AllocaInst>(GEP->getOperand(0))) {