1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define i32 @test1(i32 %X) {
5 icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
6 zext i1 %0 to i32 ; <i32>:1 [#uses=1]
9 ; CHECK: lshr i32 %X, 31
13 define i32 @test2(i32 %X) {
15 icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
16 zext i1 %0 to i32 ; <i32>:1 [#uses=1]
19 ; CHECK: lshr i32 %X, 31
24 define i32 @test3(i32 %X) {
26 icmp slt i32 %X, 0 ; <i1>:0 [#uses=1]
27 sext i1 %0 to i32 ; <i32>:1 [#uses=1]
30 ; CHECK: ashr i32 %X, 31
34 define i32 @test4(i32 %X) {
36 icmp ult i32 %X, -2147483648 ; <i1>:0 [#uses=1]
37 sext i1 %0 to i32 ; <i32>:1 [#uses=1]
40 ; CHECK: ashr i32 %X, 31
46 define <2 x i1> @test5(<2 x i64> %x) {
48 %V = icmp eq <2 x i64> %x, undef
51 ; CHECK: ret <2 x i1> <i1 true, i1 true>
54 define i32 @test6(i32 %a, i32 %b) {
55 %c = icmp sle i32 %a, -1
56 %d = zext i1 %c to i32
61 ; CHECK-NEXT: ashr i32 %a, 31
62 ; CHECK-NEXT: %f = and i32 %e, %b
63 ; CHECK-NEXT: ret i32 %f
67 define i1 @test7(i32 %x) {
70 %b = icmp ult i32 %a, %x
73 ; CHECK: %b = icmp ne i32 %x, 0
77 define i1 @test8(i32 %x){
80 %b = icmp eq i32 %a, %x
86 define i1 @test9(i32 %x) {
89 %b = icmp ugt i32 %x, %a
92 ; CHECK: icmp ugt i32 %x, 1
96 define i1 @test10(i32 %x){
99 %b = icmp slt i32 %a, %x
103 ; CHECK: %b = icmp ne i32 %x, -2147483648
107 define i1 @test11(i32 %x) {
108 %a = add nsw i32 %x, 8
109 %b = icmp slt i32 %x, %a
116 define i1 @test12(i1 %A) {
117 %S = select i1 %A, i64 -4294967295, i64 8589934591
118 %B = icmp ne i64 bitcast (<2 x i32> <i32 1, i32 -1> to i64), %S
121 ; CHECK-NEXT: %B = select i1
122 ; CHECK-NEXT: ret i1 %B
126 define i1 @test13(i8 %X) nounwind readnone {
128 %cmp = icmp slt i8 undef, %X
131 ; CHECK: ret i1 false
134 define i1 @test14(i8 %X) nounwind readnone {
136 %cmp = icmp slt i8 undef, -128
139 ; CHECK: ret i1 false
142 define i1 @test15() nounwind readnone {
144 %cmp = icmp eq i8 undef, -128
147 ; CHECK: ret i1 undef
150 define i1 @test16() nounwind readnone {
152 %cmp = icmp ne i8 undef, -128
155 ; CHECK: ret i1 undef
158 define i1 @test17(i32 %x) nounwind {
160 %and = and i32 %shl, 8
161 %cmp = icmp eq i32 %and, 0
164 ; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
168 define i1 @test18(i32 %x) nounwind {
170 %and = and i32 %sh, 1
171 %cmp = icmp eq i32 %and, 0
174 ; CHECK-NEXT: %cmp = icmp ne i32 %x, 3
177 define i1 @test19(i32 %x) nounwind {
179 %and = and i32 %shl, 8
180 %cmp = icmp eq i32 %and, 8
183 ; CHECK-NEXT: %cmp = icmp eq i32 %x, 3
186 define i1 @test20(i32 %x) nounwind {
188 %and = and i32 %shl, 8
189 %cmp = icmp ne i32 %and, 0
192 ; CHECK-NEXT: %cmp = icmp eq i32 %x, 3