diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-02-25 19:07:42 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-02-25 19:07:42 +0000 |
commit | 1e4e1c768bcbc548345348c062f402967c78c48a (patch) | |
tree | bf604e6501bfd695f1f5ad71608b1a7c8d86d3f4 /test | |
parent | 55f4ab84e567ac101d70f052771d1bc67a7560e3 (diff) | |
download | llvm-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')
-rw-r--r-- | test/Transforms/InstCombine/icmp.ll | 4 | ||||
-rw-r--r-- | test/Transforms/InstSimplify/compare.ll | 44 |
2 files changed, 45 insertions, 3 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll index dabb0f3adf..a9ae221d8f 100644 --- a/test/Transforms/InstCombine/icmp.ll +++ b/test/Transforms/InstCombine/icmp.ll @@ -634,8 +634,6 @@ define i1 @test62(i8* %a) { %arrayidx2 = getelementptr inbounds i8* %a, i64 10 %cmp = icmp slt i8* %arrayidx1, %arrayidx2 ret i1 %cmp -; Don't turn a signed cmp of GEPs into an index compare. ; CHECK: @test62 -; CHECK: %cmp = icmp slt i8* %arrayidx1, %arrayidx2 -; CHECK-NEXT: ret i1 %cmp +; CHECK-NEXT: ret i1 true } 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 |