[llvm-commits] [llvm] r127565 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Jin-Gu Kang jaykang10 at imrc.kist.re.kr
Sun Mar 13 07:05:51 PDT 2011


Author: jaykang10
Date: Sun Mar 13 09:05:51 2011
New Revision: 127565

URL: http://llvm.org/viewvc/llvm-project?rev=127565&view=rev
Log:
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

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=127565&r1=127564&r2=127565&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp Sun Mar 13 09:05:51 2011
@@ -433,6 +433,18 @@
           !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))) {





More information about the llvm-commits mailing list