summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/icmp.ll
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-10 07:11:16 +0000
committerChris Lattner <sabre@nondot.org>2011-02-10 07:11:16 +0000
commit6cdf2ea98e9952a57768a1fcdce8850089263260 (patch)
tree9e4aba745da2c2ade020bbd6c284111076e96177 /test/Transforms/InstCombine/icmp.ll
parent81baf14fdfa29c22a08d609144c285169e23a247 (diff)
downloadllvm-6cdf2ea98e9952a57768a1fcdce8850089263260.tar.gz
llvm-6cdf2ea98e9952a57768a1fcdce8850089263260.tar.bz2
llvm-6cdf2ea98e9952a57768a1fcdce8850089263260.tar.xz
implement the first part of PR8882: when lowering an inbounds
gep to explicit addressing, we know that none of the intermediate computation overflows. This could use review: it seems that the shifts certainly wouldn't overflow, but could the intermediate adds overflow if there is a negative index? Previously the testcase would instcombine to: define i1 @test(i64 %i) { %p1.idx.mask = and i64 %i, 4611686018427387903 %cmp = icmp eq i64 %p1.idx.mask, 1000 ret i1 %cmp } now we get: define i1 @test(i64 %i) { %cmp = icmp eq i64 %i, 1000 ret i1 %cmp } git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125271 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/icmp.ll')
-rw-r--r--test/Transforms/InstCombine/icmp.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/icmp.ll b/test/Transforms/InstCombine/icmp.ll
index baff2cadde..72ada2476f 100644
--- a/test/Transforms/InstCombine/icmp.ll
+++ b/test/Transforms/InstCombine/icmp.ll
@@ -1,5 +1,8 @@
; RUN: opt < %s -instcombine -S | FileCheck %s
+target datalayout =
+"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+
define i32 @test1(i32 %X) {
entry:
icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
@@ -218,3 +221,16 @@ define i1 @test23(i32 %x) nounwind {
%i4 = icmp eq i32 %i3, -1
ret i1 %i4
}
+
+@X = global [1000 x i32] zeroinitializer
+
+; PR8882
+; CHECK: @test24
+; CHECK: %cmp = icmp eq i64 %i, 1000
+; CHECK: ret i1 %cmp
+define i1 @test24(i64 %i) {
+ %p1 = getelementptr inbounds i32* getelementptr inbounds ([1000 x i32]* @X, i64 0, i64 0), i64 %i
+ %cmp = icmp eq i32* %p1, getelementptr inbounds ([1000 x i32]* @X, i64 1, i64 0)
+ ret i1 %cmp
+}
+