From 1e4e1c768bcbc548345348c062f402967c78c48a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 25 Feb 2012 19:07:42 +0000 Subject: 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 --- test/Transforms/InstSimplify/compare.ll | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'test/Transforms/InstSimplify') 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 -- cgit v1.2.3