summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Stellard <thomas.stellard@amd.com>2016-11-28 21:25:53 +0000
committerTom Stellard <thomas.stellard@amd.com>2016-11-28 21:25:53 +0000
commitafb3aea975ad2eea9102d38633a3933fcc3f6f43 (patch)
treed8970f8500b56b4340d2c247949ca474c018be05
parent75fa61d2d38673d47062bd3b817ba3f57d4a21c8 (diff)
downloadllvm-afb3aea975ad2eea9102d38633a3933fcc3f6f43.tar.gz
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. ------------------------------------------------------------------------ llvm-svn: 288066
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp2
-rw-r--r--llvm/test/Transforms/InstCombine/indexed-gep-compares.ll20
2 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index bfd73f4bbac5..961497fe3c2d 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -634,7 +634,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
}
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;
diff --git a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
index 495881549e25..64dff2712976 100644
--- a/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
+++ b/llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
@@ -167,4 +167,24 @@ lpad:
; CHECK: ret i32* %[[PTR]]
}
+
+@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(...)