summaryrefslogtreecommitdiff
path: root/test/Transforms/InstSimplify
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-02-25 19:07:42 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-02-25 19:07:42 +0000
commit1e4e1c768bcbc548345348c062f402967c78c48a (patch)
treebf604e6501bfd695f1f5ad71608b1a7c8d86d3f4 /test/Transforms/InstSimplify
parent55f4ab84e567ac101d70f052771d1bc67a7560e3 (diff)
downloadllvm-1e4e1c768bcbc548345348c062f402967c78c48a.tar.gz
llvm-1e4e1c768bcbc548345348c062f402967c78c48a.tar.bz2
llvm-1e4e1c768bcbc548345348c062f402967c78c48a.tar.xz
Teach instsimplify to be more aggressive when analyzing comparisons of pointers
by using llvm::isIdentifiedObject. Also teach it to handle GEPs that have the same base pointer and constant operands. Fixes PR11238! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstSimplify')
-rw-r--r--test/Transforms/InstSimplify/compare.ll44
1 files changed, 44 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll
index 6ee6dfbdbc..85aea19e69 100644
--- a/test/Transforms/InstSimplify/compare.ll
+++ b/test/Transforms/InstSimplify/compare.ll
@@ -40,6 +40,50 @@ define i1 @gep2() {
; CHECK-NEXT: ret i1 true
}
+; PR11238
+%t = type { i32, i32 }
+@y = global %t zeroinitializer, align 8
+
+define i1 @gep3() {
+; CHECK: @gep3
+ %x = alloca %t, align 8
+ %a = getelementptr %t* %x, i64 0, i32 0
+ %b = getelementptr %t* %x, i64 0, i32 1
+ %equal = icmp eq i32* %a, %b
+ ret i1 %equal
+; CHECK-NEXT: ret i1 false
+}
+
+define i1 @gep4() {
+; CHECK: @gep4
+ %x = alloca %t, align 8
+ %a = getelementptr %t* @y, i64 0, i32 0
+ %b = getelementptr %t* @y, i64 0, i32 1
+ %equal = icmp eq i32* %a, %b
+ ret i1 %equal
+; CHECK-NEXT: ret i1 false
+}
+
+define i1 @gep5() {
+; CHECK: @gep5
+ %x = alloca %t, align 8
+ %a = getelementptr inbounds %t* %x, i64 0, i32 1
+ %b = getelementptr %t* @y, i64 0, i32 0
+ %equal = icmp eq i32* %a, %b
+ ret i1 %equal
+; CHECK-NEXT: ret i1 false
+}
+
+define i1 @gep6(%t* %x) {
+; Same as @gep3 but potentially null.
+; CHECK: @gep6
+ %a = getelementptr %t* %x, i64 0, i32 0
+ %b = getelementptr %t* %x, i64 0, i32 1
+ %equal = icmp eq i32* %a, %b
+ ret i1 %equal
+; CHECK-NEXT: ret i1 false
+}
+
define i1 @zext(i32 %x) {
; CHECK: @zext
%e1 = zext i32 %x to i64