Merging r260427:
[oota-llvm.git] / test / CodeGen / SystemZ / int-cmp-09.ll
1 ; Test 32-bit signed comparison in which the second operand is constant.
2 ;
3 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
4
5 ; Check comparisons with 0.
6 define double @f1(double %a, double %b, i32 %i1) {
7 ; CHECK-LABEL: f1:
8 ; CHECK: cijl %r2, 0
9 ; CHECK: ldr %f0, %f2
10 ; CHECK: br %r14
11   %cond = icmp slt i32 %i1, 0
12   %res = select i1 %cond, double %a, double %b
13   ret double %res
14 }
15
16 ; Check comparisons with 2.
17 define double @f2(double %a, double %b, i32 %i1) {
18 ; CHECK-LABEL: f2:
19 ; CHECK: cijl %r2, 2
20 ; CHECK: ldr %f0, %f2
21 ; CHECK: br %r14
22   %cond = icmp slt i32 %i1, 2
23   %res = select i1 %cond, double %a, double %b
24   ret double %res
25 }
26
27 ; Check the high end of the CIJ range.
28 define double @f3(double %a, double %b, i32 %i1) {
29 ; CHECK-LABEL: f3:
30 ; CHECK: cijl %r2, 127
31 ; CHECK: ldr %f0, %f2
32 ; CHECK: br %r14
33   %cond = icmp slt i32 %i1, 127
34   %res = select i1 %cond, double %a, double %b
35   ret double %res
36 }
37
38 ; Check the next value up, which must use CHI instead.
39 define double @f4(double %a, double %b, i32 %i1) {
40 ; CHECK-LABEL: f4:
41 ; CHECK: chi %r2, 128
42 ; CHECK-NEXT: jl
43 ; CHECK: ldr %f0, %f2
44 ; CHECK: br %r14
45   %cond = icmp slt i32 %i1, 128
46   %res = select i1 %cond, double %a, double %b
47   ret double %res
48 }
49
50 ; Check the high end of the CHI range.
51 define double @f5(double %a, double %b, i32 %i1) {
52 ; CHECK-LABEL: f5:
53 ; CHECK: chi %r2, 32767
54 ; CHECK-NEXT: jl
55 ; CHECK: ldr %f0, %f2
56 ; CHECK: br %r14
57   %cond = icmp slt i32 %i1, 32767
58   %res = select i1 %cond, double %a, double %b
59   ret double %res
60 }
61
62 ; Check the next value up, which must use CFI.
63 define double @f6(double %a, double %b, i32 %i1) {
64 ; CHECK-LABEL: f6:
65 ; CHECK: cfi %r2, 32768
66 ; CHECK-NEXT: jl
67 ; CHECK: ldr %f0, %f2
68 ; CHECK: br %r14
69   %cond = icmp slt i32 %i1, 32768
70   %res = select i1 %cond, double %a, double %b
71   ret double %res
72 }
73
74 ; Check the high end of the signed 32-bit range.
75 define double @f7(double %a, double %b, i32 %i1) {
76 ; CHECK-LABEL: f7:
77 ; CHECK: cfi %r2, 2147483647
78 ; CHECK-NEXT: je
79 ; CHECK: ldr %f0, %f2
80 ; CHECK: br %r14
81   %cond = icmp eq i32 %i1, 2147483647
82   %res = select i1 %cond, double %a, double %b
83   ret double %res
84 }
85
86 ; Check the next value up, which should be treated as a negative value.
87 define double @f8(double %a, double %b, i32 %i1) {
88 ; CHECK-LABEL: f8:
89 ; CHECK: cfi %r2, -2147483648
90 ; CHECK-NEXT: je
91 ; CHECK: ldr %f0, %f2
92 ; CHECK: br %r14
93   %cond = icmp eq i32 %i1, 2147483648
94   %res = select i1 %cond, double %a, double %b
95   ret double %res
96 }
97
98 ; Check the high end of the negative CIJ range.
99 define double @f9(double %a, double %b, i32 %i1) {
100 ; CHECK-LABEL: f9:
101 ; CHECK: cijl %r2, -1
102 ; CHECK: ldr %f0, %f2
103 ; CHECK: br %r14
104   %cond = icmp slt i32 %i1, -1
105   %res = select i1 %cond, double %a, double %b
106   ret double %res
107 }
108
109 ; Check the low end of the CIJ range.
110 define double @f10(double %a, double %b, i32 %i1) {
111 ; CHECK-LABEL: f10:
112 ; CHECK: cijl %r2, -128
113 ; CHECK: ldr %f0, %f2
114 ; CHECK: br %r14
115   %cond = icmp slt i32 %i1, -128
116   %res = select i1 %cond, double %a, double %b
117   ret double %res
118 }
119
120 ; Check the next value down, which must use CHI instead.
121 define double @f11(double %a, double %b, i32 %i1) {
122 ; CHECK-LABEL: f11:
123 ; CHECK: chi %r2, -129
124 ; CHECK-NEXT: jl
125 ; CHECK: ldr %f0, %f2
126 ; CHECK: br %r14
127   %cond = icmp slt i32 %i1, -129
128   %res = select i1 %cond, double %a, double %b
129   ret double %res
130 }
131
132 ; Check the low end of the CHI range.
133 define double @f12(double %a, double %b, i32 %i1) {
134 ; CHECK-LABEL: f12:
135 ; CHECK: chi %r2, -32768
136 ; CHECK-NEXT: jl
137 ; CHECK: ldr %f0, %f2
138 ; CHECK: br %r14
139   %cond = icmp slt i32 %i1, -32768
140   %res = select i1 %cond, double %a, double %b
141   ret double %res
142 }
143
144 ; Check the next value down, which must use CFI instead.
145 define double @f13(double %a, double %b, i32 %i1) {
146 ; CHECK-LABEL: f13:
147 ; CHECK: cfi %r2, -32769
148 ; CHECK-NEXT: jl
149 ; CHECK: ldr %f0, %f2
150 ; CHECK: br %r14
151   %cond = icmp slt i32 %i1, -32769
152   %res = select i1 %cond, double %a, double %b
153   ret double %res
154 }
155
156 ; Check the low end of the signed 32-bit range.
157 define double @f14(double %a, double %b, i32 %i1) {
158 ; CHECK-LABEL: f14:
159 ; CHECK: cfi %r2, -2147483648
160 ; CHECK-NEXT: je
161 ; CHECK: ldr %f0, %f2
162 ; CHECK: br %r14
163   %cond = icmp eq i32 %i1, -2147483648
164   %res = select i1 %cond, double %a, double %b
165   ret double %res
166 }
167
168 ; Check the next value down, which should be treated as a positive value.
169 define double @f15(double %a, double %b, i32 %i1) {
170 ; CHECK-LABEL: f15:
171 ; CHECK: cfi %r2, 2147483647
172 ; CHECK-NEXT: je
173 ; CHECK: ldr %f0, %f2
174 ; CHECK: br %r14
175   %cond = icmp eq i32 %i1, -2147483649
176   %res = select i1 %cond, double %a, double %b
177   ret double %res
178 }
179
180 ; Check that < 1 becomes <= 0.
181 define double @f16(double %a, double %b, i32 %i1) {
182 ; CHECK-LABEL: f16:
183 ; CHECK: cijle %r2, 0
184 ; CHECK: ldr %f0, %f2
185 ; CHECK: br %r14
186   %cond = icmp slt i32 %i1, 1
187   %res = select i1 %cond, double %a, double %b
188   ret double %res
189 }
190
191 ; Check that >= 1 becomes > 0.
192 define double @f17(double %a, double %b, i32 %i1) {
193 ; CHECK-LABEL: f17:
194 ; CHECK: cijh %r2, 0
195 ; CHECK: ldr %f0, %f2
196 ; CHECK: br %r14
197   %cond = icmp sge i32 %i1, 1
198   %res = select i1 %cond, double %a, double %b
199   ret double %res
200 }
201
202 ; Check that > -1 becomes >= 0.
203 define double @f18(double %a, double %b, i32 %i1) {
204 ; CHECK-LABEL: f18:
205 ; CHECK: cijhe %r2, 0
206 ; CHECK: ldr %f0, %f2
207 ; CHECK: br %r14
208   %cond = icmp sgt i32 %i1, -1
209   %res = select i1 %cond, double %a, double %b
210   ret double %res
211 }
212
213 ; Check that <= -1 becomes < 0.
214 define double @f19(double %a, double %b, i32 %i1) {
215 ; CHECK-LABEL: f19:
216 ; CHECK: cijl %r2, 0
217 ; CHECK: ldr %f0, %f2
218 ; CHECK: br %r14
219   %cond = icmp sle i32 %i1, -1
220   %res = select i1 %cond, double %a, double %b
221   ret double %res
222 }