diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-03-25 21:28:14 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-03-25 21:28:14 +0000 |
commit | 58725a66c02865686c70132e8b9bd231eb66da63 (patch) | |
tree | 1d29299152f52ce1b0edeba4ded519c5f8f0dbe1 /test | |
parent | 9d9e29b4a83818b066c09c8f832cec7641aa2115 (diff) |
Teach instsimplify how to simplify comparisons of pointers which are
constant-offsets of a common base using the generic GEP-walking logic
I added for computing pointer differences in the same situation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/InstSimplify/compare.ll | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index e15bfaa84f..ced74bd4be 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -103,6 +103,68 @@ define i1 @gep8(%gept* %x) { ; CHECK: ret i1 %equal } +define i1 @gep9(i8* %ptr) { +; CHECK: @gep9 +; CHECK-NOT: ret +; CHECK: ret i1 true + +entry: + %first1 = getelementptr inbounds i8* %ptr, i32 0 + %first2 = getelementptr inbounds i8* %first1, i32 1 + %first3 = getelementptr inbounds i8* %first2, i32 2 + %first4 = getelementptr inbounds i8* %first3, i32 4 + %last1 = getelementptr inbounds i8* %first2, i32 48 + %last2 = getelementptr inbounds i8* %last1, i32 8 + %last3 = getelementptr inbounds i8* %last2, i32 -4 + %last4 = getelementptr inbounds i8* %last3, i32 -4 + %first.int = ptrtoint i8* %first4 to i32 + %last.int = ptrtoint i8* %last4 to i32 + %cmp = icmp ne i32 %last.int, %first.int + ret i1 %cmp +} + +define i1 @gep10(i8* %ptr) { +; CHECK: @gep10 +; CHECK-NOT: ret +; CHECK: ret i1 true + +entry: + %first1 = getelementptr inbounds i8* %ptr, i32 -2 + %first2 = getelementptr inbounds i8* %first1, i32 44 + %last1 = getelementptr inbounds i8* %ptr, i32 48 + %last2 = getelementptr inbounds i8* %last1, i32 -6 + %first.int = ptrtoint i8* %first2 to i32 + %last.int = ptrtoint i8* %last2 to i32 + %cmp = icmp eq i32 %last.int, %first.int + ret i1 %cmp +} + +define i1 @gep11(i8* %ptr) { +; CHECK: @gep11 +; CHECK-NOT: ret +; CHECK: ret i1 true + +entry: + %first1 = getelementptr inbounds i8* %ptr, i32 -2 + %last1 = getelementptr inbounds i8* %ptr, i32 48 + %last2 = getelementptr inbounds i8* %last1, i32 -6 + %cmp = icmp ult i8* %first1, %last2 + ret i1 %cmp +} + +define i1 @gep12(i8* %ptr) { +; CHECK: @gep12 +; CHECK-NOT: ret +; CHECK: ret i1 %cmp + +entry: + %first1 = getelementptr inbounds i8* %ptr, i32 -2 + %last1 = getelementptr inbounds i8* %ptr, i32 48 + %last2 = getelementptr inbounds i8* %last1, i32 -6 + %cmp = icmp slt i8* %first1, %last2 + ret i1 %cmp +} + define i1 @zext(i32 %x) { ; CHECK: @zext %e1 = zext i32 %x to i64 |