[llvm-branch-commits] [llvm-branch] r288066 - Merging r281650:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 28 13:25:54 PST 2016


Author: tstellar
Date: Mon Nov 28 15:25:53 2016
New Revision: 288066

URL: http://llvm.org/viewvc/llvm-project?rev=288066&view=rev
Log:
Merging r281650:

------------------------------------------------------------------------
r281650 | david.majnemer | 2016-09-15 13:10:09 -0700 (Thu, 15 Sep 2016) | 6 lines

[InstCombine] Do not RAUW a constant GEP

canRewriteGEPAsOffset expects to process instructions, not constants.

This fixes PR30342.

------------------------------------------------------------------------

Modified:
    llvm/branches/release_39/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/branches/release_39/test/Transforms/InstCombine/indexed-gep-compares.ll

Modified: llvm/branches/release_39/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=288066&r1=288065&r2=288066&view=diff
==============================================================================
--- llvm/branches/release_39/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/branches/release_39/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Nov 28 15:25:53 2016
@@ -634,7 +634,7 @@ static bool canRewriteGEPAsOffset(Value
       }
 
       if (!isa<IntToPtrInst>(V) && !isa<PtrToIntInst>(V) &&
-          !isa<GEPOperator>(V) && !isa<PHINode>(V))
+          !isa<GetElementPtrInst>(V) && !isa<PHINode>(V))
         // We've found some value that we can't explore which is different from
         // the base. Therefore we can't do this transformation.
         return false;

Modified: llvm/branches/release_39/test/Transforms/InstCombine/indexed-gep-compares.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_39/test/Transforms/InstCombine/indexed-gep-compares.ll?rev=288066&r1=288065&r2=288066&view=diff
==============================================================================
--- llvm/branches/release_39/test/Transforms/InstCombine/indexed-gep-compares.ll (original)
+++ llvm/branches/release_39/test/Transforms/InstCombine/indexed-gep-compares.ll Mon Nov 28 15:25:53 2016
@@ -167,4 +167,24 @@ lpad:
 ; CHECK:  ret i32* %[[PTR]]
 }
 
+
+ at pr30402 = constant i64 3
+define i1 @test7() {
+entry:
+  br label %bb7
+
+bb7:                                              ; preds = %bb10, %entry-block
+  %phi = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
+  %cmp = icmp eq i64* %phi, getelementptr inbounds (i64, i64* @pr30402, i32 1)
+  br i1 %cmp, label %bb10, label %bb7
+
+bb10:
+  ret i1 %cmp
+}
+; CHECK-LABEL: @test7(
+; CHECK:  %[[phi:.*]] = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
+; CHECK:  %[[cmp:.*]] = icmp eq i64* %[[phi]], getelementptr inbounds (i64, i64* @pr30402, i32 1)
+; CHECK: ret i1 %[[cmp]]
+
+
 declare i32 @__gxx_personality_v0(...)




More information about the llvm-branch-commits mailing list