diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-02-26 02:09:49 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-02-26 02:09:49 +0000 |
commit | f7087ea5088d58e81f08a3eeb39ba46fa18d0fd4 (patch) | |
tree | 74e5926d44cc460ced13b2223e73f8b87c7259f3 /test/Transforms/InstSimplify/compare.ll | |
parent | 8c727f9200cd54adc4a1b742950e80035bc53a20 (diff) |
Reinstate the optimization from r151449 with a fix to not turn 'gep %x' into
'gep null' when the icmp predicate is unsigned (or is signed without inbounds).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstSimplify/compare.ll')
-rw-r--r-- | test/Transforms/InstSimplify/compare.ll | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll index 6ee6dfbdbc..e15bfaa84f 100644 --- a/test/Transforms/InstSimplify/compare.ll +++ b/test/Transforms/InstSimplify/compare.ll @@ -40,6 +40,69 @@ define i1 @gep2() { ; CHECK-NEXT: ret i1 true } +; PR11238 +%gept = type { i32, i32 } +@gepy = global %gept zeroinitializer, align 8 +@gepz = extern_weak global %gept + +define i1 @gep3() { +; CHECK: @gep3 + %x = alloca %gept, align 8 + %a = getelementptr %gept* %x, i64 0, i32 0 + %b = getelementptr %gept* %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 %gept, align 8 + %a = getelementptr %gept* @gepy, i64 0, i32 0 + %b = getelementptr %gept* @gepy, 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 %gept, align 8 + %a = getelementptr inbounds %gept* %x, i64 0, i32 1 + %b = getelementptr %gept* @gepy, i64 0, i32 0 + %equal = icmp eq i32* %a, %b + ret i1 %equal +; CHECK-NEXT: ret i1 false +} + +define i1 @gep6(%gept* %x) { +; Same as @gep3 but potentially null. +; CHECK: @gep6 + %a = getelementptr %gept* %x, i64 0, i32 0 + %b = getelementptr %gept* %x, i64 0, i32 1 + %equal = icmp eq i32* %a, %b + ret i1 %equal +; CHECK-NEXT: ret i1 false +} + +define i1 @gep7(%gept* %x) { +; CHECK: @gep7 + %a = getelementptr %gept* %x, i64 0, i32 0 + %b = getelementptr %gept* @gepz, i64 0, i32 0 + %equal = icmp eq i32* %a, %b + ret i1 %equal +; CHECK: ret i1 %equal +} + +define i1 @gep8(%gept* %x) { +; CHECK: @gep8 + %a = getelementptr %gept* %x, i32 1 + %b = getelementptr %gept* %x, i32 -1 + %equal = icmp ugt %gept* %a, %b + ret i1 %equal +; CHECK: ret i1 %equal +} + define i1 @zext(i32 %x) { ; CHECK: @zext %e1 = zext i32 %x to i64 |