1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; This is https://bugs.llvm.org/show_bug.cgi?id=36682
6 ; In *all* of these, sitofp and bitcast should be instcombine'd out.
7 ; "sle 0" is canonicalized to "slt 1", so we don't test "sle 0" case.
8 ; "sge 0" is canonicalized to "sgt -1", so we don't test "sge 0" case.
9 ; "sge 1" is canonicalized to "sgt 0", so we don't test "sge 1" case.
10 ; "sle -1" is canonicalized to "slt 0", so we don't test "sle -1" case.
12 define i1 @i32_cast_cmp_eq_int_0_sitofp_float(i32 %i) {
13 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float(
14 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
15 ; CHECK-NEXT: ret i1 [[CMP]]
17 %f = sitofp i32 %i to float
18 %b = bitcast float %f to i32
19 %cmp = icmp eq i32 %b, 0
23 define i1 @i32_cast_cmp_ne_int_0_sitofp_float(i32 %i) {
24 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_float(
25 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
26 ; CHECK-NEXT: ret i1 [[CMP]]
28 %f = sitofp i32 %i to float
29 %b = bitcast float %f to i32
30 %cmp = icmp ne i32 %b, 0
34 define i1 @i32_cast_cmp_slt_int_0_sitofp_float(i32 %i) {
35 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_float(
36 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0
37 ; CHECK-NEXT: ret i1 [[CMP]]
39 %f = sitofp i32 %i to float
40 %b = bitcast float %f to i32
41 %cmp = icmp slt i32 %b, 0
45 define i1 @i32_cast_cmp_sgt_int_0_sitofp_float(i32 %i) {
46 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_float(
47 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0
48 ; CHECK-NEXT: ret i1 [[CMP]]
50 %f = sitofp i32 %i to float
51 %b = bitcast float %f to i32
52 %cmp = icmp sgt i32 %b, 0
56 define i1 @i32_cast_cmp_slt_int_1_sitofp_float(i32 %i) {
57 ; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_float(
58 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1
59 ; CHECK-NEXT: ret i1 [[CMP]]
61 %f = sitofp i32 %i to float
62 %b = bitcast float %f to i32
63 %cmp = icmp slt i32 %b, 1
67 define i1 @i32_cast_cmp_sgt_int_m1_sitofp_float(i32 %i) {
68 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_float(
69 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1
70 ; CHECK-NEXT: ret i1 [[CMP]]
72 %f = sitofp i32 %i to float
73 %b = bitcast float %f to i32
74 %cmp = icmp sgt i32 %b, -1
78 define i1 @i32_cast_cmp_eq_int_0_sitofp_double(i32 %i) {
79 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_double(
80 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
81 ; CHECK-NEXT: ret i1 [[CMP]]
83 %f = sitofp i32 %i to double
84 %b = bitcast double %f to i64
85 %cmp = icmp eq i64 %b, 0
89 define i1 @i32_cast_cmp_ne_int_0_sitofp_double(i32 %i) {
90 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double(
91 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
92 ; CHECK-NEXT: ret i1 [[CMP]]
94 %f = sitofp i32 %i to double
95 %b = bitcast double %f to i64
96 %cmp = icmp ne i64 %b, 0
100 define i1 @i32_cast_cmp_slt_int_0_sitofp_double(i32 %i) {
101 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_double(
102 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0
103 ; CHECK-NEXT: ret i1 [[CMP]]
105 %f = sitofp i32 %i to double
106 %b = bitcast double %f to i64
107 %cmp = icmp slt i64 %b, 0
111 define i1 @i32_cast_cmp_sgt_int_0_sitofp_double(i32 %i) {
112 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_double(
113 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0
114 ; CHECK-NEXT: ret i1 [[CMP]]
116 %f = sitofp i32 %i to double
117 %b = bitcast double %f to i64
118 %cmp = icmp sgt i64 %b, 0
122 define i1 @i32_cast_cmp_slt_int_1_sitofp_double(i32 %i) {
123 ; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_double(
124 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1
125 ; CHECK-NEXT: ret i1 [[CMP]]
127 %f = sitofp i32 %i to double
128 %b = bitcast double %f to i64
129 %cmp = icmp slt i64 %b, 1
133 define i1 @i32_cast_cmp_sgt_int_m1_sitofp_double(i32 %i) {
134 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_double(
135 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1
136 ; CHECK-NEXT: ret i1 [[CMP]]
138 %f = sitofp i32 %i to double
139 %b = bitcast double %f to i64
140 %cmp = icmp sgt i64 %b, -1
144 define i1 @i32_cast_cmp_eq_int_0_sitofp_half(i32 %i) {
145 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_half(
146 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0
147 ; CHECK-NEXT: ret i1 [[CMP]]
149 %f = sitofp i32 %i to half
150 %b = bitcast half %f to i16
151 %cmp = icmp eq i16 %b, 0
155 define i1 @i32_cast_cmp_ne_int_0_sitofp_half(i32 %i) {
156 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_half(
157 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0
158 ; CHECK-NEXT: ret i1 [[CMP]]
160 %f = sitofp i32 %i to half
161 %b = bitcast half %f to i16
162 %cmp = icmp ne i16 %b, 0
166 define i1 @i32_cast_cmp_slt_int_0_sitofp_half(i32 %i) {
167 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_sitofp_half(
168 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 0
169 ; CHECK-NEXT: ret i1 [[CMP]]
171 %f = sitofp i32 %i to half
172 %b = bitcast half %f to i16
173 %cmp = icmp slt i16 %b, 0
177 define i1 @i32_cast_cmp_sgt_int_0_sitofp_half(i32 %i) {
178 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_0_sitofp_half(
179 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], 0
180 ; CHECK-NEXT: ret i1 [[CMP]]
182 %f = sitofp i32 %i to half
183 %b = bitcast half %f to i16
184 %cmp = icmp sgt i16 %b, 0
188 define i1 @i32_cast_cmp_slt_int_1_sitofp_half(i32 %i) {
189 ; CHECK-LABEL: @i32_cast_cmp_slt_int_1_sitofp_half(
190 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], 1
191 ; CHECK-NEXT: ret i1 [[CMP]]
193 %f = sitofp i32 %i to half
194 %b = bitcast half %f to i16
195 %cmp = icmp slt i16 %b, 1
199 define i1 @i32_cast_cmp_sgt_int_m1_sitofp_half(i32 %i) {
200 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_sitofp_half(
201 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[I:%.*]], -1
202 ; CHECK-NEXT: ret i1 [[CMP]]
204 %f = sitofp i32 %i to half
205 %b = bitcast half %f to i16
206 %cmp = icmp sgt i16 %b, -1
210 define i1 @i64_cast_cmp_eq_int_0_sitofp_float(i64 %i) {
211 ; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_float(
212 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0
213 ; CHECK-NEXT: ret i1 [[CMP]]
215 %f = sitofp i64 %i to float
216 %b = bitcast float %f to i32
217 %cmp = icmp eq i32 %b, 0
221 define i1 @i64_cast_cmp_ne_int_0_sitofp_float(i64 %i) {
222 ; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_float(
223 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0
224 ; CHECK-NEXT: ret i1 [[CMP]]
226 %f = sitofp i64 %i to float
227 %b = bitcast float %f to i32
228 %cmp = icmp ne i32 %b, 0
232 define i1 @i64_cast_cmp_slt_int_0_sitofp_float(i64 %i) {
233 ; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_float(
234 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0
235 ; CHECK-NEXT: ret i1 [[CMP]]
237 %f = sitofp i64 %i to float
238 %b = bitcast float %f to i32
239 %cmp = icmp slt i32 %b, 0
243 define i1 @i64_cast_cmp_sgt_int_0_sitofp_float(i64 %i) {
244 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_float(
245 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0
246 ; CHECK-NEXT: ret i1 [[CMP]]
248 %f = sitofp i64 %i to float
249 %b = bitcast float %f to i32
250 %cmp = icmp sgt i32 %b, 0
254 define i1 @i64_cast_cmp_slt_int_1_sitofp_float(i64 %i) {
255 ; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_float(
256 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1
257 ; CHECK-NEXT: ret i1 [[CMP]]
259 %f = sitofp i64 %i to float
260 %b = bitcast float %f to i32
261 %cmp = icmp slt i32 %b, 1
265 define i1 @i64_cast_cmp_sgt_int_m1_sitofp_float(i64 %i) {
266 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_float(
267 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1
268 ; CHECK-NEXT: ret i1 [[CMP]]
270 %f = sitofp i64 %i to float
271 %b = bitcast float %f to i32
272 %cmp = icmp sgt i32 %b, -1
276 define i1 @i64_cast_cmp_eq_int_0_sitofp_double(i64 %i) {
277 ; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_double(
278 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0
279 ; CHECK-NEXT: ret i1 [[CMP]]
281 %f = sitofp i64 %i to double
282 %b = bitcast double %f to i64
283 %cmp = icmp eq i64 %b, 0
287 define i1 @i64_cast_cmp_ne_int_0_sitofp_double(i64 %i) {
288 ; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_double(
289 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0
290 ; CHECK-NEXT: ret i1 [[CMP]]
292 %f = sitofp i64 %i to double
293 %b = bitcast double %f to i64
294 %cmp = icmp ne i64 %b, 0
298 define i1 @i64_cast_cmp_slt_int_0_sitofp_double(i64 %i) {
299 ; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_double(
300 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0
301 ; CHECK-NEXT: ret i1 [[CMP]]
303 %f = sitofp i64 %i to double
304 %b = bitcast double %f to i64
305 %cmp = icmp slt i64 %b, 0
309 define i1 @i64_cast_cmp_sgt_int_0_sitofp_double(i64 %i) {
310 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_double(
311 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0
312 ; CHECK-NEXT: ret i1 [[CMP]]
314 %f = sitofp i64 %i to double
315 %b = bitcast double %f to i64
316 %cmp = icmp sgt i64 %b, 0
320 define i1 @i64_cast_cmp_slt_int_1_sitofp_double(i64 %i) {
321 ; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_double(
322 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1
323 ; CHECK-NEXT: ret i1 [[CMP]]
325 %f = sitofp i64 %i to double
326 %b = bitcast double %f to i64
327 %cmp = icmp slt i64 %b, 1
331 define i1 @i64_cast_cmp_sgt_int_m1_sitofp_double(i64 %i) {
332 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_double(
333 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1
334 ; CHECK-NEXT: ret i1 [[CMP]]
336 %f = sitofp i64 %i to double
337 %b = bitcast double %f to i64
338 %cmp = icmp sgt i64 %b, -1
342 define i1 @i64_cast_cmp_eq_int_0_sitofp_half(i64 %i) {
343 ; CHECK-LABEL: @i64_cast_cmp_eq_int_0_sitofp_half(
344 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[I:%.*]], 0
345 ; CHECK-NEXT: ret i1 [[CMP]]
347 %f = sitofp i64 %i to half
348 %b = bitcast half %f to i16
349 %cmp = icmp eq i16 %b, 0
353 define i1 @i64_cast_cmp_ne_int_0_sitofp_half(i64 %i) {
354 ; CHECK-LABEL: @i64_cast_cmp_ne_int_0_sitofp_half(
355 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i64 [[I:%.*]], 0
356 ; CHECK-NEXT: ret i1 [[CMP]]
358 %f = sitofp i64 %i to half
359 %b = bitcast half %f to i16
360 %cmp = icmp ne i16 %b, 0
364 define i1 @i64_cast_cmp_slt_int_0_sitofp_half(i64 %i) {
365 ; CHECK-LABEL: @i64_cast_cmp_slt_int_0_sitofp_half(
366 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 0
367 ; CHECK-NEXT: ret i1 [[CMP]]
369 %f = sitofp i64 %i to half
370 %b = bitcast half %f to i16
371 %cmp = icmp slt i16 %b, 0
375 define i1 @i64_cast_cmp_sgt_int_0_sitofp_half(i64 %i) {
376 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_0_sitofp_half(
377 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], 0
378 ; CHECK-NEXT: ret i1 [[CMP]]
380 %f = sitofp i64 %i to half
381 %b = bitcast half %f to i16
382 %cmp = icmp sgt i16 %b, 0
386 define i1 @i64_cast_cmp_slt_int_1_sitofp_half(i64 %i) {
387 ; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half(
388 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I:%.*]], 1
389 ; CHECK-NEXT: ret i1 [[CMP]]
391 %f = sitofp i64 %i to half
392 %b = bitcast half %f to i16
393 %cmp = icmp slt i16 %b, 1
397 define i1 @i64_cast_cmp_sgt_int_m1_sitofp_half(i64 %i) {
398 ; CHECK-LABEL: @i64_cast_cmp_sgt_int_m1_sitofp_half(
399 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i64 [[I:%.*]], -1
400 ; CHECK-NEXT: ret i1 [[CMP]]
402 %f = sitofp i64 %i to half
403 %b = bitcast half %f to i16
404 %cmp = icmp sgt i16 %b, -1
408 define i1 @i16_cast_cmp_eq_int_0_sitofp_float(i16 %i) {
409 ; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_float(
410 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0
411 ; CHECK-NEXT: ret i1 [[CMP]]
413 %f = sitofp i16 %i to float
414 %b = bitcast float %f to i32
415 %cmp = icmp eq i32 %b, 0
419 define i1 @i16_cast_cmp_ne_int_0_sitofp_float(i16 %i) {
420 ; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_float(
421 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0
422 ; CHECK-NEXT: ret i1 [[CMP]]
424 %f = sitofp i16 %i to float
425 %b = bitcast float %f to i32
426 %cmp = icmp ne i32 %b, 0
430 define i1 @i16_cast_cmp_slt_int_0_sitofp_float(i16 %i) {
431 ; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_float(
432 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0
433 ; CHECK-NEXT: ret i1 [[CMP]]
435 %f = sitofp i16 %i to float
436 %b = bitcast float %f to i32
437 %cmp = icmp slt i32 %b, 0
441 define i1 @i16_cast_cmp_sgt_int_0_sitofp_float(i16 %i) {
442 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_float(
443 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0
444 ; CHECK-NEXT: ret i1 [[CMP]]
446 %f = sitofp i16 %i to float
447 %b = bitcast float %f to i32
448 %cmp = icmp sgt i32 %b, 0
452 define i1 @i16_cast_cmp_slt_int_1_sitofp_float(i16 %i) {
453 ; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_float(
454 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1
455 ; CHECK-NEXT: ret i1 [[CMP]]
457 %f = sitofp i16 %i to float
458 %b = bitcast float %f to i32
459 %cmp = icmp slt i32 %b, 1
463 define i1 @i16_cast_cmp_sgt_int_m1_sitofp_float(i16 %i) {
464 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float(
465 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1
466 ; CHECK-NEXT: ret i1 [[CMP]]
468 %f = sitofp i16 %i to float
469 %b = bitcast float %f to i32
470 %cmp = icmp sgt i32 %b, -1
474 define i1 @i16_cast_cmp_eq_int_0_sitofp_double(i16 %i) {
475 ; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_double(
476 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0
477 ; CHECK-NEXT: ret i1 [[CMP]]
479 %f = sitofp i16 %i to double
480 %b = bitcast double %f to i64
481 %cmp = icmp eq i64 %b, 0
485 define i1 @i16_cast_cmp_ne_int_0_sitofp_double(i16 %i) {
486 ; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_double(
487 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0
488 ; CHECK-NEXT: ret i1 [[CMP]]
490 %f = sitofp i16 %i to double
491 %b = bitcast double %f to i64
492 %cmp = icmp ne i64 %b, 0
496 define i1 @i16_cast_cmp_slt_int_0_sitofp_double(i16 %i) {
497 ; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_double(
498 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0
499 ; CHECK-NEXT: ret i1 [[CMP]]
501 %f = sitofp i16 %i to double
502 %b = bitcast double %f to i64
503 %cmp = icmp slt i64 %b, 0
507 define i1 @i16_cast_cmp_sgt_int_0_sitofp_double(i16 %i) {
508 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_double(
509 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0
510 ; CHECK-NEXT: ret i1 [[CMP]]
512 %f = sitofp i16 %i to double
513 %b = bitcast double %f to i64
514 %cmp = icmp sgt i64 %b, 0
518 define i1 @i16_cast_cmp_slt_int_1_sitofp_double(i16 %i) {
519 ; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_double(
520 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1
521 ; CHECK-NEXT: ret i1 [[CMP]]
523 %f = sitofp i16 %i to double
524 %b = bitcast double %f to i64
525 %cmp = icmp slt i64 %b, 1
529 define i1 @i16_cast_cmp_sgt_int_m1_sitofp_double(i16 %i) {
530 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_double(
531 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1
532 ; CHECK-NEXT: ret i1 [[CMP]]
534 %f = sitofp i16 %i to double
535 %b = bitcast double %f to i64
536 %cmp = icmp sgt i64 %b, -1
540 define i1 @i16_cast_cmp_eq_int_0_sitofp_half(i16 %i) {
541 ; CHECK-LABEL: @i16_cast_cmp_eq_int_0_sitofp_half(
542 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[I:%.*]], 0
543 ; CHECK-NEXT: ret i1 [[CMP]]
545 %f = sitofp i16 %i to half
546 %b = bitcast half %f to i16
547 %cmp = icmp eq i16 %b, 0
551 define i1 @i16_cast_cmp_ne_int_0_sitofp_half(i16 %i) {
552 ; CHECK-LABEL: @i16_cast_cmp_ne_int_0_sitofp_half(
553 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i16 [[I:%.*]], 0
554 ; CHECK-NEXT: ret i1 [[CMP]]
556 %f = sitofp i16 %i to half
557 %b = bitcast half %f to i16
558 %cmp = icmp ne i16 %b, 0
562 define i1 @i16_cast_cmp_slt_int_0_sitofp_half(i16 %i) {
563 ; CHECK-LABEL: @i16_cast_cmp_slt_int_0_sitofp_half(
564 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 0
565 ; CHECK-NEXT: ret i1 [[CMP]]
567 %f = sitofp i16 %i to half
568 %b = bitcast half %f to i16
569 %cmp = icmp slt i16 %b, 0
573 define i1 @i16_cast_cmp_sgt_int_0_sitofp_half(i16 %i) {
574 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_0_sitofp_half(
575 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], 0
576 ; CHECK-NEXT: ret i1 [[CMP]]
578 %f = sitofp i16 %i to half
579 %b = bitcast half %f to i16
580 %cmp = icmp sgt i16 %b, 0
584 define i1 @i16_cast_cmp_slt_int_1_sitofp_half(i16 %i) {
585 ; CHECK-LABEL: @i16_cast_cmp_slt_int_1_sitofp_half(
586 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i16 [[I:%.*]], 1
587 ; CHECK-NEXT: ret i1 [[CMP]]
589 %f = sitofp i16 %i to half
590 %b = bitcast half %f to i16
591 %cmp = icmp slt i16 %b, 1
595 define i1 @i16_cast_cmp_sgt_int_m1_sitofp_half(i16 %i) {
596 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_half(
597 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i16 [[I:%.*]], -1
598 ; CHECK-NEXT: ret i1 [[CMP]]
600 %f = sitofp i16 %i to half
601 %b = bitcast half %f to i16
602 %cmp = icmp sgt i16 %b, -1
606 ; Verify that vector types and vector constants including undef elements are transformed too.
608 define <3 x i1> @i32_cast_cmp_ne_int_0_sitofp_double_vec(<3 x i32> %i) {
609 ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_sitofp_double_vec(
610 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[I:%.*]], zeroinitializer
611 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
613 %f = sitofp <3 x i32> %i to <3 x double>
614 %b = bitcast <3 x double> %f to <3 x i64>
615 %cmp = icmp ne <3 x i64> %b, <i64 0, i64 0, i64 0>
619 ; TODO: Can we propagate the constant vector with undef element?
621 define <3 x i1> @i32_cast_cmp_eq_int_0_sitofp_float_vec_undef(<3 x i32> %i) {
622 ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_sitofp_float_vec_undef(
623 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[I:%.*]], zeroinitializer
624 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
626 %f = sitofp <3 x i32> %i to <3 x float>
627 %b = bitcast <3 x float> %f to <3 x i32>
628 %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0>
632 define <3 x i1> @i64_cast_cmp_slt_int_1_sitofp_half_vec_undef(<3 x i64> %i) {
633 ; CHECK-LABEL: @i64_cast_cmp_slt_int_1_sitofp_half_vec_undef(
634 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt <3 x i64> [[I:%.*]], <i64 1, i64 1, i64 1>
635 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
637 %f = sitofp <3 x i64> %i to <3 x half>
638 %b = bitcast <3 x half> %f to <3 x i16>
639 %cmp = icmp slt <3 x i16> %b, <i16 1, i16 undef, i16 1>
643 define <3 x i1> @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_undef(<3 x i16> %i) {
644 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_sitofp_float_vec_undef(
645 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <3 x i16> [[I:%.*]], <i16 -1, i16 -1, i16 -1>
646 ; CHECK-NEXT: ret <3 x i1> [[CMP]]
648 %f = sitofp <3 x i16> %i to <3 x float>
649 %b = bitcast <3 x float> %f to <3 x i32>
650 %cmp = icmp sgt <3 x i32> %b, <i32 -1, i32 undef, i32 -1>
654 ; Verify that the various forms of this transform are not applied when the
655 ; bitcast changes the number of vector elements:
656 ; icmp (bitcast ([su]itofp X)), Y -> icmp X, Y
658 define <6 x i1> @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(<3 x i16> %i) {
659 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_num_elements_sitofp(
660 ; CHECK-NEXT: [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float>
661 ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16>
662 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <6 x i16> [[B]], <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
663 ; CHECK-NEXT: ret <6 x i1> [[CMP]]
665 %f = sitofp <3 x i16> %i to <3 x float>
666 %b = bitcast <3 x float> %f to <6 x i16>
667 %cmp = icmp sgt <6 x i16> %b, <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1>
671 define i1 @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(<3 x i16> %i) {
672 ; CHECK-LABEL: @i16_cast_cmp_sgt_int_m1_bitcast_vector_to_scalar_sitofp(
673 ; CHECK-NEXT: [[F:%.*]] = sitofp <3 x i16> [[I:%.*]] to <3 x float>
674 ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to i96
675 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i96 [[B]], -1
676 ; CHECK-NEXT: ret i1 [[CMP]]
678 %f = sitofp <3 x i16> %i to <3 x float>
679 %b = bitcast <3 x float> %f to i96
680 %cmp = icmp sgt i96 %b, -1
685 define <6 x i1> @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(<3 x i16> %i) {
686 ; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_num_elements_uitofp(
687 ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float>
688 ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <6 x i16>
689 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <6 x i16> [[B]], zeroinitializer
690 ; CHECK-NEXT: ret <6 x i1> [[CMP]]
692 %f = uitofp <3 x i16> %i to <3 x float>
693 %b = bitcast <3 x float> %f to <6 x i16>
694 %cmp = icmp eq <6 x i16> %b, <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0>
698 define i1 @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(<3 x i16> %i) {
699 ; CHECK-LABEL: @i16_cast_cmp_eq_int_0_bitcast_vector_to_scalar_uitofp(
700 ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i16> [[I:%.*]] to <3 x float>
701 ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to i96
702 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i96 [[B]], 0
703 ; CHECK-NEXT: ret i1 [[CMP]]
705 %f = uitofp <3 x i16> %i to <3 x float>
706 %b = bitcast <3 x float> %f to i96
707 %cmp = icmp eq i96 %b, 0