|
| 1 | +From 7801978ec1f3637fcda1b564048ebc732bf586af Mon Sep 17 00:00:00 2001 |
| 2 | +From: Simonas Kazlauskas < [email protected]> |
| 3 | +Date: Fri, 16 Sep 2016 00:32:20 +0300 |
| 4 | +Subject: [PATCH] Backport rL281650 |
| 5 | + |
| 6 | +--- |
| 7 | + lib/Transforms/InstCombine/InstCombineCompares.cpp | 2 +- |
| 8 | + test/Transforms/InstCombine/indexed-gep-compares.ll | 20 ++++++++++++++++++++ |
| 9 | + 2 files changed, 21 insertions(+), 1 deletion(-) |
| 10 | + |
| 11 | +diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp |
| 12 | +index bfd73f4bbac5..961497fe3c2d 100644 |
| 13 | +--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp |
| 14 | ++++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp |
| 15 | +@@ -634,7 +634,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base, |
| 16 | + } |
| 17 | + |
| 18 | + if (!isa<IntToPtrInst>(V) && !isa<PtrToIntInst>(V) && |
| 19 | +- !isa<GEPOperator>(V) && !isa<PHINode>(V)) |
| 20 | ++ !isa<GetElementPtrInst>(V) && !isa<PHINode>(V)) |
| 21 | + // We've found some value that we can't explore which is different from |
| 22 | + // the base. Therefore we can't do this transformation. |
| 23 | + return false; |
| 24 | +diff --git a/test/Transforms/InstCombine/indexed-gep-compares.ll b/test/Transforms/InstCombine/indexed-gep-compares.ll |
| 25 | +index 495881549e25..64dff2712976 100644 |
| 26 | +--- a/test/Transforms/InstCombine/indexed-gep-compares.ll |
| 27 | ++++ b/test/Transforms/InstCombine/indexed-gep-compares.ll |
| 28 | +@@ -167,4 +167,24 @@ lpad: |
| 29 | + ; CHECK: ret i32* %[[PTR]] |
| 30 | + } |
| 31 | + |
| 32 | ++ |
| 33 | ++@pr30402 = constant i64 3 |
| 34 | ++define i1 @test7() { |
| 35 | ++entry: |
| 36 | ++ br label %bb7 |
| 37 | ++ |
| 38 | ++bb7: ; preds = %bb10, %entry-block |
| 39 | ++ %phi = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ] |
| 40 | ++ %cmp = icmp eq i64* %phi, getelementptr inbounds (i64, i64* @pr30402, i32 1) |
| 41 | ++ br i1 %cmp, label %bb10, label %bb7 |
| 42 | ++ |
| 43 | ++bb10: |
| 44 | ++ ret i1 %cmp |
| 45 | ++} |
| 46 | ++; CHECK-LABEL: @test7( |
| 47 | ++; CHECK: %[[phi:.*]] = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ] |
| 48 | ++; CHECK: %[[cmp:.*]] = icmp eq i64* %[[phi]], getelementptr inbounds (i64, i64* @pr30402, i32 1) |
| 49 | ++; CHECK: ret i1 %[[cmp]] |
| 50 | ++ |
| 51 | ++ |
| 52 | + declare i32 @__gxx_personality_v0(...) |
| 53 | +-- |
| 54 | +2.7.4 |
| 55 | + |
0 commit comments