1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; There are 12 basic patterns (or 6 with DeMorganized equivalent) with
5 ; 2 (commute logic op) *
6 ; 2 (swap compare operands) *
8 ; variations for a total of 96 tests.
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
12 ; (X == MAX) && (X < Y) --> false
14 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16 define i1 @slt_and_max(i8 %x, i8 %y) {
17 ; CHECK-LABEL: @slt_and_max(
18 ; CHECK-NEXT: ret i1 false
20 %cmp = icmp slt i8 %x, %y
21 %cmpeq = icmp eq i8 %x, 127
22 %r = and i1 %cmp, %cmpeq
26 define i1 @slt_and_max_logical(i8 %x, i8 %y) {
27 ; CHECK-LABEL: @slt_and_max_logical(
28 ; CHECK-NEXT: ret i1 false
30 %cmp = icmp slt i8 %x, %y
31 %cmpeq = icmp eq i8 %x, 127
32 %r = select i1 %cmp, i1 %cmpeq, i1 false
36 define <2 x i1> @slt_and_max_commute(<2 x i8> %x, <2 x i8> %y) {
37 ; CHECK-LABEL: @slt_and_max_commute(
38 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
40 %cmp = icmp slt <2 x i8> %x, %y
41 %cmpeq = icmp eq <2 x i8> %x, <i8 127, i8 127>
42 %r = and <2 x i1> %cmpeq, %cmp
46 define i1 @slt_swap_and_max(i8 %x, i8 %y) {
47 ; CHECK-LABEL: @slt_swap_and_max(
48 ; CHECK-NEXT: ret i1 false
50 %cmp = icmp sgt i8 %y, %x
51 %cmpeq = icmp eq i8 %x, 127
52 %r = and i1 %cmp, %cmpeq
56 define i1 @slt_swap_and_max_logical(i8 %x, i8 %y) {
57 ; CHECK-LABEL: @slt_swap_and_max_logical(
58 ; CHECK-NEXT: ret i1 false
60 %cmp = icmp sgt i8 %y, %x
61 %cmpeq = icmp eq i8 %x, 127
62 %r = select i1 %cmp, i1 %cmpeq, i1 false
66 define i1 @slt_swap_and_max_commute(i8 %x, i8 %y) {
67 ; CHECK-LABEL: @slt_swap_and_max_commute(
68 ; CHECK-NEXT: ret i1 false
70 %cmp = icmp sgt i8 %y, %x
71 %cmpeq = icmp eq i8 %x, 127
72 %r = and i1 %cmpeq, %cmp
76 define i1 @slt_swap_and_max_commute_logical(i8 %x, i8 %y) {
77 ; CHECK-LABEL: @slt_swap_and_max_commute_logical(
78 ; CHECK-NEXT: ret i1 false
80 %cmp = icmp sgt i8 %y, %x
81 %cmpeq = icmp eq i8 %x, 127
82 %r = select i1 %cmpeq, i1 %cmp, i1 false
86 define i1 @ult_and_max(i8 %x, i8 %y) {
87 ; CHECK-LABEL: @ult_and_max(
88 ; CHECK-NEXT: ret i1 false
90 %cmp = icmp ult i8 %x, %y
91 %cmpeq = icmp eq i8 %x, 255
92 %r = and i1 %cmp, %cmpeq
96 define i1 @ult_and_max_logical(i8 %x, i8 %y) {
97 ; CHECK-LABEL: @ult_and_max_logical(
98 ; CHECK-NEXT: ret i1 false
100 %cmp = icmp ult i8 %x, %y
101 %cmpeq = icmp eq i8 %x, 255
102 %r = select i1 %cmp, i1 %cmpeq, i1 false
106 define i1 @ult_and_max_commute(i8 %x, i8 %y) {
107 ; CHECK-LABEL: @ult_and_max_commute(
108 ; CHECK-NEXT: ret i1 false
110 %cmp = icmp ult i8 %x, %y
111 %cmpeq = icmp eq i8 %x, 255
112 %r = and i1 %cmpeq, %cmp
116 define i1 @ult_and_max_commute_logical(i8 %x, i8 %y) {
117 ; CHECK-LABEL: @ult_and_max_commute_logical(
118 ; CHECK-NEXT: ret i1 false
120 %cmp = icmp ult i8 %x, %y
121 %cmpeq = icmp eq i8 %x, 255
122 %r = select i1 %cmpeq, i1 %cmp, i1 false
126 define i1 @ult_swap_and_max(i8 %x, i8 %y) {
127 ; CHECK-LABEL: @ult_swap_and_max(
128 ; CHECK-NEXT: ret i1 false
130 %cmp = icmp ugt i8 %y, %x
131 %cmpeq = icmp eq i8 %x, 255
132 %r = and i1 %cmp, %cmpeq
136 define i1 @ult_swap_and_max_logical(i8 %x, i8 %y) {
137 ; CHECK-LABEL: @ult_swap_and_max_logical(
138 ; CHECK-NEXT: ret i1 false
140 %cmp = icmp ugt i8 %y, %x
141 %cmpeq = icmp eq i8 %x, 255
142 %r = select i1 %cmp, i1 %cmpeq, i1 false
146 define i1 @ult_swap_and_max_commute(i8 %x, i8 %y) {
147 ; CHECK-LABEL: @ult_swap_and_max_commute(
148 ; CHECK-NEXT: ret i1 false
150 %cmp = icmp ugt i8 %y, %x
151 %cmpeq = icmp eq i8 %x, 255
152 %r = and i1 %cmpeq, %cmp
156 define i1 @ult_swap_and_max_commute_logical(i8 %x, i8 %y) {
157 ; CHECK-LABEL: @ult_swap_and_max_commute_logical(
158 ; CHECK-NEXT: ret i1 false
160 %cmp = icmp ugt i8 %y, %x
161 %cmpeq = icmp eq i8 %x, 255
162 %r = select i1 %cmpeq, i1 %cmp, i1 false
166 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168 ; (X == MIN) && (X > Y) --> false
170 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
172 define i1 @sgt_and_min(i9 %x, i9 %y) {
173 ; CHECK-LABEL: @sgt_and_min(
174 ; CHECK-NEXT: ret i1 false
176 %cmp = icmp sgt i9 %x, %y
177 %cmpeq = icmp eq i9 %x, 256
178 %r = and i1 %cmp, %cmpeq
182 define i1 @sgt_and_min_logical(i9 %x, i9 %y) {
183 ; CHECK-LABEL: @sgt_and_min_logical(
184 ; CHECK-NEXT: ret i1 false
186 %cmp = icmp sgt i9 %x, %y
187 %cmpeq = icmp eq i9 %x, 256
188 %r = select i1 %cmp, i1 %cmpeq, i1 false
192 define i1 @sgt_and_min_commute(i8 %x, i8 %y) {
193 ; CHECK-LABEL: @sgt_and_min_commute(
194 ; CHECK-NEXT: ret i1 false
196 %cmp = icmp sgt i8 %x, %y
197 %cmpeq = icmp eq i8 %x, 128
198 %r = and i1 %cmpeq, %cmp
202 define i1 @sgt_and_min_commute_logical(i8 %x, i8 %y) {
203 ; CHECK-LABEL: @sgt_and_min_commute_logical(
204 ; CHECK-NEXT: ret i1 false
206 %cmp = icmp sgt i8 %x, %y
207 %cmpeq = icmp eq i8 %x, 128
208 %r = select i1 %cmpeq, i1 %cmp, i1 false
212 define i1 @sgt_swap_and_min(i8 %x, i8 %y) {
213 ; CHECK-LABEL: @sgt_swap_and_min(
214 ; CHECK-NEXT: ret i1 false
216 %cmp = icmp slt i8 %y, %x
217 %cmpeq = icmp eq i8 %x, 128
218 %r = and i1 %cmp, %cmpeq
222 define i1 @sgt_swap_and_min_logical(i8 %x, i8 %y) {
223 ; CHECK-LABEL: @sgt_swap_and_min_logical(
224 ; CHECK-NEXT: ret i1 false
226 %cmp = icmp slt i8 %y, %x
227 %cmpeq = icmp eq i8 %x, 128
228 %r = select i1 %cmp, i1 %cmpeq, i1 false
232 define i1 @sgt_swap_and_min_commute(i8 %x, i8 %y) {
233 ; CHECK-LABEL: @sgt_swap_and_min_commute(
234 ; CHECK-NEXT: ret i1 false
236 %cmp = icmp slt i8 %y, %x
237 %cmpeq = icmp eq i8 %x, 128
238 %r = and i1 %cmpeq, %cmp
242 define i1 @sgt_swap_and_min_commute_logical(i8 %x, i8 %y) {
243 ; CHECK-LABEL: @sgt_swap_and_min_commute_logical(
244 ; CHECK-NEXT: ret i1 false
246 %cmp = icmp slt i8 %y, %x
247 %cmpeq = icmp eq i8 %x, 128
248 %r = select i1 %cmpeq, i1 %cmp, i1 false
252 define i1 @ugt_and_min(i8 %x, i8 %y) {
253 ; CHECK-LABEL: @ugt_and_min(
254 ; CHECK-NEXT: ret i1 false
256 %cmp = icmp ugt i8 %x, %y
257 %cmpeq = icmp eq i8 %x, 0
258 %r = and i1 %cmp, %cmpeq
262 define i1 @ugt_and_min_logical(i8 %x, i8 %y) {
263 ; CHECK-LABEL: @ugt_and_min_logical(
264 ; CHECK-NEXT: ret i1 false
266 %cmp = icmp ugt i8 %x, %y
267 %cmpeq = icmp eq i8 %x, 0
268 %r = select i1 %cmp, i1 %cmpeq, i1 false
272 define i1 @ugt_and_min_commute(i8 %x, i8 %y) {
273 ; CHECK-LABEL: @ugt_and_min_commute(
274 ; CHECK-NEXT: ret i1 false
276 %cmp = icmp ugt i8 %x, %y
277 %cmpeq = icmp eq i8 %x, 0
278 %r = and i1 %cmpeq, %cmp
282 define i1 @ugt_and_min_commute_logical(i8 %x, i8 %y) {
283 ; CHECK-LABEL: @ugt_and_min_commute_logical(
284 ; CHECK-NEXT: ret i1 false
286 %cmp = icmp ugt i8 %x, %y
287 %cmpeq = icmp eq i8 %x, 0
288 %r = select i1 %cmpeq, i1 %cmp, i1 false
292 define i1 @ugt_swap_and_min(i8 %x, i8 %y) {
293 ; CHECK-LABEL: @ugt_swap_and_min(
294 ; CHECK-NEXT: ret i1 false
296 %cmp = icmp ult i8 %y, %x
297 %cmpeq = icmp eq i8 %x, 0
298 %r = and i1 %cmp, %cmpeq
302 define i1 @ugt_swap_and_min_logical(i8 %x, i8 %y) {
303 ; CHECK-LABEL: @ugt_swap_and_min_logical(
304 ; CHECK-NEXT: ret i1 false
306 %cmp = icmp ult i8 %y, %x
307 %cmpeq = icmp eq i8 %x, 0
308 %r = select i1 %cmp, i1 %cmpeq, i1 false
312 define i1 @ugt_swap_and_min_commute(i8 %x, i8 %y) {
313 ; CHECK-LABEL: @ugt_swap_and_min_commute(
314 ; CHECK-NEXT: ret i1 false
316 %cmp = icmp ult i8 %y, %x
317 %cmpeq = icmp eq i8 %x, 0
318 %r = and i1 %cmpeq, %cmp
322 define i1 @ugt_swap_and_min_commute_logical(i8 %x, i8 %y) {
323 ; CHECK-LABEL: @ugt_swap_and_min_commute_logical(
324 ; CHECK-NEXT: ret i1 false
326 %cmp = icmp ult i8 %y, %x
327 %cmpeq = icmp eq i8 %x, 0
328 %r = select i1 %cmpeq, i1 %cmp, i1 false
332 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
334 ; (X != MAX) || (X >= Y) --> true
336 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
338 define i1 @sge_or_not_max(i8 %x, i8 %y) {
339 ; CHECK-LABEL: @sge_or_not_max(
340 ; CHECK-NEXT: ret i1 true
342 %cmp = icmp sge i8 %x, %y
343 %cmpeq = icmp ne i8 %x, 127
344 %r = or i1 %cmp, %cmpeq
348 define i1 @sge_or_not_max_logical(i8 %x, i8 %y) {
349 ; CHECK-LABEL: @sge_or_not_max_logical(
350 ; CHECK-NEXT: ret i1 true
352 %cmp = icmp sge i8 %x, %y
353 %cmpeq = icmp ne i8 %x, 127
354 %r = select i1 %cmp, i1 true, i1 %cmpeq
358 define i1 @sge_or_not_max_commute(i8 %x, i8 %y) {
359 ; CHECK-LABEL: @sge_or_not_max_commute(
360 ; CHECK-NEXT: ret i1 true
362 %cmp = icmp sge i8 %x, %y
363 %cmpeq = icmp ne i8 %x, 127
364 %r = or i1 %cmpeq, %cmp
368 define i1 @sge_or_not_max_commute_logical(i8 %x, i8 %y) {
369 ; CHECK-LABEL: @sge_or_not_max_commute_logical(
370 ; CHECK-NEXT: ret i1 true
372 %cmp = icmp sge i8 %x, %y
373 %cmpeq = icmp ne i8 %x, 127
374 %r = select i1 %cmpeq, i1 true, i1 %cmp
378 define i1 @sge_swap_or_not_max(i8 %x, i8 %y) {
379 ; CHECK-LABEL: @sge_swap_or_not_max(
380 ; CHECK-NEXT: ret i1 true
382 %cmp = icmp sle i8 %y, %x
383 %cmpeq = icmp ne i8 %x, 127
384 %r = or i1 %cmp, %cmpeq
388 define i1 @sge_swap_or_not_max_logical(i8 %x, i8 %y) {
389 ; CHECK-LABEL: @sge_swap_or_not_max_logical(
390 ; CHECK-NEXT: ret i1 true
392 %cmp = icmp sle i8 %y, %x
393 %cmpeq = icmp ne i8 %x, 127
394 %r = select i1 %cmp, i1 true, i1 %cmpeq
398 define i1 @sge_swap_or_not_max_commute(i8 %x, i8 %y) {
399 ; CHECK-LABEL: @sge_swap_or_not_max_commute(
400 ; CHECK-NEXT: ret i1 true
402 %cmp = icmp sle i8 %y, %x
403 %cmpeq = icmp ne i8 %x, 127
404 %r = or i1 %cmpeq, %cmp
408 define i1 @sge_swap_or_not_max_commute_logical(i8 %x, i8 %y) {
409 ; CHECK-LABEL: @sge_swap_or_not_max_commute_logical(
410 ; CHECK-NEXT: ret i1 true
412 %cmp = icmp sle i8 %y, %x
413 %cmpeq = icmp ne i8 %x, 127
414 %r = select i1 %cmpeq, i1 true, i1 %cmp
418 define i1 @uge_or_not_max(i8 %x, i8 %y) {
419 ; CHECK-LABEL: @uge_or_not_max(
420 ; CHECK-NEXT: ret i1 true
422 %cmp = icmp uge i8 %x, %y
423 %cmpeq = icmp ne i8 %x, 255
424 %r = or i1 %cmp, %cmpeq
428 define i1 @uge_or_not_max_logical(i8 %x, i8 %y) {
429 ; CHECK-LABEL: @uge_or_not_max_logical(
430 ; CHECK-NEXT: ret i1 true
432 %cmp = icmp uge i8 %x, %y
433 %cmpeq = icmp ne i8 %x, 255
434 %r = select i1 %cmp, i1 true, i1 %cmpeq
438 define i1 @uge_or_not_max_commute(i8 %x, i8 %y) {
439 ; CHECK-LABEL: @uge_or_not_max_commute(
440 ; CHECK-NEXT: ret i1 true
442 %cmp = icmp uge i8 %x, %y
443 %cmpeq = icmp ne i8 %x, 255
444 %r = or i1 %cmpeq, %cmp
448 define i1 @uge_or_not_max_commute_logical(i8 %x, i8 %y) {
449 ; CHECK-LABEL: @uge_or_not_max_commute_logical(
450 ; CHECK-NEXT: ret i1 true
452 %cmp = icmp uge i8 %x, %y
453 %cmpeq = icmp ne i8 %x, 255
454 %r = select i1 %cmpeq, i1 true, i1 %cmp
458 define i1 @uge_swap_or_not_max(i8 %x, i8 %y) {
459 ; CHECK-LABEL: @uge_swap_or_not_max(
460 ; CHECK-NEXT: ret i1 true
462 %cmp = icmp ule i8 %y, %x
463 %cmpeq = icmp ne i8 %x, 255
464 %r = or i1 %cmp, %cmpeq
468 define i1 @uge_swap_or_not_max_logical(i8 %x, i8 %y) {
469 ; CHECK-LABEL: @uge_swap_or_not_max_logical(
470 ; CHECK-NEXT: ret i1 true
472 %cmp = icmp ule i8 %y, %x
473 %cmpeq = icmp ne i8 %x, 255
474 %r = select i1 %cmp, i1 true, i1 %cmpeq
478 define i1 @uge_swap_or_not_max_commute(i8 %x, i8 %y) {
479 ; CHECK-LABEL: @uge_swap_or_not_max_commute(
480 ; CHECK-NEXT: ret i1 true
482 %cmp = icmp ule i8 %y, %x
483 %cmpeq = icmp ne i8 %x, 255
484 %r = or i1 %cmpeq, %cmp
488 define i1 @uge_swap_or_not_max_commute_logical(i8 %x, i8 %y) {
489 ; CHECK-LABEL: @uge_swap_or_not_max_commute_logical(
490 ; CHECK-NEXT: ret i1 true
492 %cmp = icmp ule i8 %y, %x
493 %cmpeq = icmp ne i8 %x, 255
494 %r = select i1 %cmpeq, i1 true, i1 %cmp
498 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
500 ; (X != MIN) || (X <= Y) --> true
502 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
504 define i1 @sle_or_not_min(i8 %x, i8 %y) {
505 ; CHECK-LABEL: @sle_or_not_min(
506 ; CHECK-NEXT: ret i1 true
508 %cmp = icmp sle i8 %x, %y
509 %cmpeq = icmp ne i8 %x, 128
510 %r = or i1 %cmp, %cmpeq
514 define i1 @sle_or_not_min_logical(i8 %x, i8 %y) {
515 ; CHECK-LABEL: @sle_or_not_min_logical(
516 ; CHECK-NEXT: ret i1 true
518 %cmp = icmp sle i8 %x, %y
519 %cmpeq = icmp ne i8 %x, 128
520 %r = select i1 %cmp, i1 true, i1 %cmpeq
524 define i1 @sle_or_not_min_commute(i8 %x, i8 %y) {
525 ; CHECK-LABEL: @sle_or_not_min_commute(
526 ; CHECK-NEXT: ret i1 true
528 %cmp = icmp sle i8 %x, %y
529 %cmpeq = icmp ne i8 %x, 128
530 %r = or i1 %cmpeq, %cmp
534 define i1 @sle_or_not_min_commute_logical(i8 %x, i8 %y) {
535 ; CHECK-LABEL: @sle_or_not_min_commute_logical(
536 ; CHECK-NEXT: ret i1 true
538 %cmp = icmp sle i8 %x, %y
539 %cmpeq = icmp ne i8 %x, 128
540 %r = select i1 %cmpeq, i1 true, i1 %cmp
544 define i1 @sle_swap_or_not_min(i8 %x, i8 %y) {
545 ; CHECK-LABEL: @sle_swap_or_not_min(
546 ; CHECK-NEXT: ret i1 true
548 %cmp = icmp sge i8 %y, %x
549 %cmpeq = icmp ne i8 %x, 128
550 %r = or i1 %cmp, %cmpeq
554 define i1 @sle_swap_or_not_min_logical(i8 %x, i8 %y) {
555 ; CHECK-LABEL: @sle_swap_or_not_min_logical(
556 ; CHECK-NEXT: ret i1 true
558 %cmp = icmp sge i8 %y, %x
559 %cmpeq = icmp ne i8 %x, 128
560 %r = select i1 %cmp, i1 true, i1 %cmpeq
564 define i1 @sle_swap_or_not_min_commute(i8 %x, i8 %y) {
565 ; CHECK-LABEL: @sle_swap_or_not_min_commute(
566 ; CHECK-NEXT: ret i1 true
568 %cmp = icmp sge i8 %y, %x
569 %cmpeq = icmp ne i8 %x, 128
570 %r = or i1 %cmpeq, %cmp
574 define i1 @sle_swap_or_not_min_commute_logical(i8 %x, i8 %y) {
575 ; CHECK-LABEL: @sle_swap_or_not_min_commute_logical(
576 ; CHECK-NEXT: ret i1 true
578 %cmp = icmp sge i8 %y, %x
579 %cmpeq = icmp ne i8 %x, 128
580 %r = select i1 %cmpeq, i1 true, i1 %cmp
584 define i1 @ule_or_not_min(i427 %x, i427 %y) {
585 ; CHECK-LABEL: @ule_or_not_min(
586 ; CHECK-NEXT: ret i1 true
588 %cmp = icmp ule i427 %x, %y
589 %cmpeq = icmp ne i427 %x, 0
590 %r = or i1 %cmp, %cmpeq
594 define i1 @ule_or_not_min_logical(i427 %x, i427 %y) {
595 ; CHECK-LABEL: @ule_or_not_min_logical(
596 ; CHECK-NEXT: ret i1 true
598 %cmp = icmp ule i427 %x, %y
599 %cmpeq = icmp ne i427 %x, 0
600 %r = select i1 %cmp, i1 true, i1 %cmpeq
604 define i1 @ule_or_not_min_commute(i8 %x, i8 %y) {
605 ; CHECK-LABEL: @ule_or_not_min_commute(
606 ; CHECK-NEXT: ret i1 true
608 %cmp = icmp ule i8 %x, %y
609 %cmpeq = icmp ne i8 %x, 0
610 %r = or i1 %cmpeq, %cmp
614 define i1 @ule_or_not_min_commute_logical(i8 %x, i8 %y) {
615 ; CHECK-LABEL: @ule_or_not_min_commute_logical(
616 ; CHECK-NEXT: ret i1 true
618 %cmp = icmp ule i8 %x, %y
619 %cmpeq = icmp ne i8 %x, 0
620 %r = select i1 %cmpeq, i1 true, i1 %cmp
624 define i1 @ule_swap_or_not_min(i8 %x, i8 %y) {
625 ; CHECK-LABEL: @ule_swap_or_not_min(
626 ; CHECK-NEXT: ret i1 true
628 %cmp = icmp uge i8 %y, %x
629 %cmpeq = icmp ne i8 %x, 0
630 %r = or i1 %cmp, %cmpeq
634 define i1 @ule_swap_or_not_min_logical(i8 %x, i8 %y) {
635 ; CHECK-LABEL: @ule_swap_or_not_min_logical(
636 ; CHECK-NEXT: ret i1 true
638 %cmp = icmp uge i8 %y, %x
639 %cmpeq = icmp ne i8 %x, 0
640 %r = select i1 %cmp, i1 true, i1 %cmpeq
644 define i1 @ule_swap_or_not_min_commute(i8 %x, i8 %y) {
645 ; CHECK-LABEL: @ule_swap_or_not_min_commute(
646 ; CHECK-NEXT: ret i1 true
648 %cmp = icmp uge i8 %y, %x
649 %cmpeq = icmp ne i8 %x, 0
650 %r = or i1 %cmpeq, %cmp
654 define i1 @ule_swap_or_not_min_commute_logical(i8 %x, i8 %y) {
655 ; CHECK-LABEL: @ule_swap_or_not_min_commute_logical(
656 ; CHECK-NEXT: ret i1 true
658 %cmp = icmp uge i8 %y, %x
659 %cmpeq = icmp ne i8 %x, 0
660 %r = select i1 %cmpeq, i1 true, i1 %cmp
664 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
666 ; (X == MAX) && (X >= Y) --> X == MAX
668 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
670 define i1 @sge_and_max(i8 %x, i8 %y) {
671 ; CHECK-LABEL: @sge_and_max(
672 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
673 ; CHECK-NEXT: ret i1 [[CMPEQ]]
675 %cmp = icmp sge i8 %x, %y
676 %cmpeq = icmp eq i8 %x, 127
677 %r = and i1 %cmp, %cmpeq
681 define i1 @sge_and_max_logical(i8 %x, i8 %y) {
682 ; CHECK-LABEL: @sge_and_max_logical(
683 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
684 ; CHECK-NEXT: ret i1 [[CMPEQ]]
686 %cmp = icmp sge i8 %x, %y
687 %cmpeq = icmp eq i8 %x, 127
688 %r = select i1 %cmp, i1 %cmpeq, i1 false
692 define i1 @sge_and_max_commute(i8 %x, i8 %y) {
693 ; CHECK-LABEL: @sge_and_max_commute(
694 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
695 ; CHECK-NEXT: ret i1 [[CMPEQ]]
697 %cmp = icmp sge i8 %x, %y
698 %cmpeq = icmp eq i8 %x, 127
699 %r = and i1 %cmpeq, %cmp
703 define i1 @sge_and_max_commute_logical(i8 %x, i8 %y) {
704 ; CHECK-LABEL: @sge_and_max_commute_logical(
705 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
706 ; CHECK-NEXT: ret i1 [[CMPEQ]]
708 %cmp = icmp sge i8 %x, %y
709 %cmpeq = icmp eq i8 %x, 127
710 %r = select i1 %cmpeq, i1 %cmp, i1 false
714 define i1 @sge_swap_and_max(i8 %x, i8 %y) {
715 ; CHECK-LABEL: @sge_swap_and_max(
716 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
717 ; CHECK-NEXT: ret i1 [[CMPEQ]]
719 %cmp = icmp sle i8 %y, %x
720 %cmpeq = icmp eq i8 %x, 127
721 %r = and i1 %cmp, %cmpeq
725 define i1 @sge_swap_and_max_logical(i8 %x, i8 %y) {
726 ; CHECK-LABEL: @sge_swap_and_max_logical(
727 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
728 ; CHECK-NEXT: ret i1 [[CMPEQ]]
730 %cmp = icmp sle i8 %y, %x
731 %cmpeq = icmp eq i8 %x, 127
732 %r = select i1 %cmp, i1 %cmpeq, i1 false
736 define i1 @sge_swap_and_max_commute(i8 %x, i8 %y) {
737 ; CHECK-LABEL: @sge_swap_and_max_commute(
738 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
739 ; CHECK-NEXT: ret i1 [[CMPEQ]]
741 %cmp = icmp sle i8 %y, %x
742 %cmpeq = icmp eq i8 %x, 127
743 %r = and i1 %cmpeq, %cmp
747 define i1 @sge_swap_and_max_commute_logical(i8 %x, i8 %y) {
748 ; CHECK-LABEL: @sge_swap_and_max_commute_logical(
749 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 127
750 ; CHECK-NEXT: ret i1 [[CMPEQ]]
752 %cmp = icmp sle i8 %y, %x
753 %cmpeq = icmp eq i8 %x, 127
754 %r = select i1 %cmpeq, i1 %cmp, i1 false
758 define i1 @uge_and_max(i8 %x, i8 %y) {
759 ; CHECK-LABEL: @uge_and_max(
760 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
761 ; CHECK-NEXT: ret i1 [[CMPEQ]]
763 %cmp = icmp uge i8 %x, %y
764 %cmpeq = icmp eq i8 %x, 255
765 %r = and i1 %cmp, %cmpeq
769 define i1 @uge_and_max_logical(i8 %x, i8 %y) {
770 ; CHECK-LABEL: @uge_and_max_logical(
771 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
772 ; CHECK-NEXT: ret i1 [[CMPEQ]]
774 %cmp = icmp uge i8 %x, %y
775 %cmpeq = icmp eq i8 %x, 255
776 %r = select i1 %cmp, i1 %cmpeq, i1 false
780 define i1 @uge_and_max_commute(i8 %x, i8 %y) {
781 ; CHECK-LABEL: @uge_and_max_commute(
782 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
783 ; CHECK-NEXT: ret i1 [[CMPEQ]]
785 %cmp = icmp uge i8 %x, %y
786 %cmpeq = icmp eq i8 %x, 255
787 %r = and i1 %cmpeq, %cmp
791 define i1 @uge_and_max_commute_logical(i8 %x, i8 %y) {
792 ; CHECK-LABEL: @uge_and_max_commute_logical(
793 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
794 ; CHECK-NEXT: ret i1 [[CMPEQ]]
796 %cmp = icmp uge i8 %x, %y
797 %cmpeq = icmp eq i8 %x, 255
798 %r = select i1 %cmpeq, i1 %cmp, i1 false
802 define i1 @uge_swap_and_max(i8 %x, i8 %y) {
803 ; CHECK-LABEL: @uge_swap_and_max(
804 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
805 ; CHECK-NEXT: ret i1 [[CMPEQ]]
807 %cmp = icmp ule i8 %y, %x
808 %cmpeq = icmp eq i8 %x, 255
809 %r = and i1 %cmp, %cmpeq
813 define i1 @uge_swap_and_max_logical(i8 %x, i8 %y) {
814 ; CHECK-LABEL: @uge_swap_and_max_logical(
815 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
816 ; CHECK-NEXT: ret i1 [[CMPEQ]]
818 %cmp = icmp ule i8 %y, %x
819 %cmpeq = icmp eq i8 %x, 255
820 %r = select i1 %cmp, i1 %cmpeq, i1 false
824 define i1 @uge_swap_and_max_commute(i8 %x, i8 %y) {
825 ; CHECK-LABEL: @uge_swap_and_max_commute(
826 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
827 ; CHECK-NEXT: ret i1 [[CMPEQ]]
829 %cmp = icmp ule i8 %y, %x
830 %cmpeq = icmp eq i8 %x, 255
831 %r = and i1 %cmpeq, %cmp
835 define i1 @uge_swap_and_max_commute_logical(i8 %x, i8 %y) {
836 ; CHECK-LABEL: @uge_swap_and_max_commute_logical(
837 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -1
838 ; CHECK-NEXT: ret i1 [[CMPEQ]]
840 %cmp = icmp ule i8 %y, %x
841 %cmpeq = icmp eq i8 %x, 255
842 %r = select i1 %cmpeq, i1 %cmp, i1 false
846 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
848 ; (X == MIN) && (X <= Y) --> X == MIN
850 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
852 define i1 @sle_and_min(i8 %x, i8 %y) {
853 ; CHECK-LABEL: @sle_and_min(
854 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
855 ; CHECK-NEXT: ret i1 [[CMPEQ]]
857 %cmp = icmp sle i8 %x, %y
858 %cmpeq = icmp eq i8 %x, 128
859 %r = and i1 %cmp, %cmpeq
863 define i1 @sle_and_min_logical(i8 %x, i8 %y) {
864 ; CHECK-LABEL: @sle_and_min_logical(
865 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
866 ; CHECK-NEXT: ret i1 [[CMPEQ]]
868 %cmp = icmp sle i8 %x, %y
869 %cmpeq = icmp eq i8 %x, 128
870 %r = select i1 %cmp, i1 %cmpeq, i1 false
874 define i1 @sle_and_min_commute(i8 %x, i8 %y) {
875 ; CHECK-LABEL: @sle_and_min_commute(
876 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
877 ; CHECK-NEXT: ret i1 [[CMPEQ]]
879 %cmp = icmp sle i8 %x, %y
880 %cmpeq = icmp eq i8 %x, 128
881 %r = and i1 %cmpeq, %cmp
885 define i1 @sle_and_min_commute_logical(i8 %x, i8 %y) {
886 ; CHECK-LABEL: @sle_and_min_commute_logical(
887 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
888 ; CHECK-NEXT: ret i1 [[CMPEQ]]
890 %cmp = icmp sle i8 %x, %y
891 %cmpeq = icmp eq i8 %x, 128
892 %r = select i1 %cmpeq, i1 %cmp, i1 false
896 define i1 @sle_swap_and_min(i8 %x, i8 %y) {
897 ; CHECK-LABEL: @sle_swap_and_min(
898 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
899 ; CHECK-NEXT: ret i1 [[CMPEQ]]
901 %cmp = icmp sge i8 %y, %x
902 %cmpeq = icmp eq i8 %x, 128
903 %r = and i1 %cmp, %cmpeq
907 define i1 @sle_swap_and_min_logical(i8 %x, i8 %y) {
908 ; CHECK-LABEL: @sle_swap_and_min_logical(
909 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
910 ; CHECK-NEXT: ret i1 [[CMPEQ]]
912 %cmp = icmp sge i8 %y, %x
913 %cmpeq = icmp eq i8 %x, 128
914 %r = select i1 %cmp, i1 %cmpeq, i1 false
918 define i1 @sle_swap_and_min_commute(i8 %x, i8 %y) {
919 ; CHECK-LABEL: @sle_swap_and_min_commute(
920 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
921 ; CHECK-NEXT: ret i1 [[CMPEQ]]
923 %cmp = icmp sge i8 %y, %x
924 %cmpeq = icmp eq i8 %x, 128
925 %r = and i1 %cmpeq, %cmp
929 define i1 @sle_swap_and_min_commute_logical(i8 %x, i8 %y) {
930 ; CHECK-LABEL: @sle_swap_and_min_commute_logical(
931 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], -128
932 ; CHECK-NEXT: ret i1 [[CMPEQ]]
934 %cmp = icmp sge i8 %y, %x
935 %cmpeq = icmp eq i8 %x, 128
936 %r = select i1 %cmpeq, i1 %cmp, i1 false
940 define i1 @ule_and_min(i8 %x, i8 %y) {
941 ; CHECK-LABEL: @ule_and_min(
942 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
943 ; CHECK-NEXT: ret i1 [[CMPEQ]]
945 %cmp = icmp ule i8 %x, %y
946 %cmpeq = icmp eq i8 %x, 0
947 %r = and i1 %cmp, %cmpeq
951 define i1 @ule_and_min_logical(i8 %x, i8 %y) {
952 ; CHECK-LABEL: @ule_and_min_logical(
953 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
954 ; CHECK-NEXT: ret i1 [[CMPEQ]]
956 %cmp = icmp ule i8 %x, %y
957 %cmpeq = icmp eq i8 %x, 0
958 %r = select i1 %cmp, i1 %cmpeq, i1 false
962 define i1 @ule_and_min_commute(i8 %x, i8 %y) {
963 ; CHECK-LABEL: @ule_and_min_commute(
964 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
965 ; CHECK-NEXT: ret i1 [[CMPEQ]]
967 %cmp = icmp ule i8 %x, %y
968 %cmpeq = icmp eq i8 %x, 0
969 %r = and i1 %cmpeq, %cmp
973 define i1 @ule_and_min_commute_logical(i8 %x, i8 %y) {
974 ; CHECK-LABEL: @ule_and_min_commute_logical(
975 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
976 ; CHECK-NEXT: ret i1 [[CMPEQ]]
978 %cmp = icmp ule i8 %x, %y
979 %cmpeq = icmp eq i8 %x, 0
980 %r = select i1 %cmpeq, i1 %cmp, i1 false
984 define i1 @ule_swap_and_min(i8 %x, i8 %y) {
985 ; CHECK-LABEL: @ule_swap_and_min(
986 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
987 ; CHECK-NEXT: ret i1 [[CMPEQ]]
989 %cmp = icmp uge i8 %y, %x
990 %cmpeq = icmp eq i8 %x, 0
991 %r = and i1 %cmp, %cmpeq
995 define i1 @ule_swap_and_min_logical(i8 %x, i8 %y) {
996 ; CHECK-LABEL: @ule_swap_and_min_logical(
997 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
998 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1000 %cmp = icmp uge i8 %y, %x
1001 %cmpeq = icmp eq i8 %x, 0
1002 %r = select i1 %cmp, i1 %cmpeq, i1 false
1006 define i1 @ule_swap_and_min_commute(i8 %x, i8 %y) {
1007 ; CHECK-LABEL: @ule_swap_and_min_commute(
1008 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
1009 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1011 %cmp = icmp uge i8 %y, %x
1012 %cmpeq = icmp eq i8 %x, 0
1013 %r = and i1 %cmpeq, %cmp
1017 define i1 @ule_swap_and_min_commute_logical(i8 %x, i8 %y) {
1018 ; CHECK-LABEL: @ule_swap_and_min_commute_logical(
1019 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
1020 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1022 %cmp = icmp uge i8 %y, %x
1023 %cmpeq = icmp eq i8 %x, 0
1024 %r = select i1 %cmpeq, i1 %cmp, i1 false
1028 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1030 ; (X == MAX) || (X >= Y) --> X >= Y
1032 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1034 define i1 @sge_or_max(i8 %x, i8 %y) {
1035 ; CHECK-LABEL: @sge_or_max(
1036 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
1037 ; CHECK-NEXT: ret i1 [[CMP]]
1039 %cmp = icmp sge i8 %x, %y
1040 %cmpeq = icmp eq i8 %x, 127
1041 %r = or i1 %cmp, %cmpeq
1045 define i1 @sge_or_max_logical(i8 %x, i8 %y) {
1046 ; CHECK-LABEL: @sge_or_max_logical(
1047 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
1048 ; CHECK-NEXT: ret i1 [[CMP]]
1050 %cmp = icmp sge i8 %x, %y
1051 %cmpeq = icmp eq i8 %x, 127
1052 %r = select i1 %cmp, i1 true, i1 %cmpeq
1056 define i1 @sge_or_max_commute(i8 %x, i8 %y) {
1057 ; CHECK-LABEL: @sge_or_max_commute(
1058 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
1059 ; CHECK-NEXT: ret i1 [[CMP]]
1061 %cmp = icmp sge i8 %x, %y
1062 %cmpeq = icmp eq i8 %x, 127
1063 %r = or i1 %cmpeq, %cmp
1067 define i1 @sge_or_max_commute_logical(i8 %x, i8 %y) {
1068 ; CHECK-LABEL: @sge_or_max_commute_logical(
1069 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
1070 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
1071 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1072 ; CHECK-NEXT: ret i1 [[R]]
1074 %cmp = icmp sge i8 %x, %y
1075 %cmpeq = icmp eq i8 %x, 127
1076 %r = select i1 %cmpeq, i1 true, i1 %cmp
1080 define i1 @sge_swap_or_max(i8 %x, i8 %y) {
1081 ; CHECK-LABEL: @sge_swap_or_max(
1082 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
1083 ; CHECK-NEXT: ret i1 [[CMP]]
1085 %cmp = icmp sle i8 %y, %x
1086 %cmpeq = icmp eq i8 %x, 127
1087 %r = or i1 %cmp, %cmpeq
1091 define i1 @sge_swap_or_max_logical(i8 %x, i8 %y) {
1092 ; CHECK-LABEL: @sge_swap_or_max_logical(
1093 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
1094 ; CHECK-NEXT: ret i1 [[CMP]]
1096 %cmp = icmp sle i8 %y, %x
1097 %cmpeq = icmp eq i8 %x, 127
1098 %r = select i1 %cmp, i1 true, i1 %cmpeq
1102 define i1 @sge_swap_or_max_commute(i8 %x, i8 %y) {
1103 ; CHECK-LABEL: @sge_swap_or_max_commute(
1104 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
1105 ; CHECK-NEXT: ret i1 [[CMP]]
1107 %cmp = icmp sle i8 %y, %x
1108 %cmpeq = icmp eq i8 %x, 127
1109 %r = or i1 %cmpeq, %cmp
1113 define i1 @sge_swap_or_max_commute_logical(i8 %x, i8 %y) {
1114 ; CHECK-LABEL: @sge_swap_or_max_commute_logical(
1115 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
1116 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
1117 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1118 ; CHECK-NEXT: ret i1 [[R]]
1120 %cmp = icmp sle i8 %y, %x
1121 %cmpeq = icmp eq i8 %x, 127
1122 %r = select i1 %cmpeq, i1 true, i1 %cmp
1126 define i1 @uge_or_max(i8 %x, i8 %y) {
1127 ; CHECK-LABEL: @uge_or_max(
1128 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1129 ; CHECK-NEXT: ret i1 [[CMP]]
1131 %cmp = icmp uge i8 %x, %y
1132 %cmpeq = icmp eq i8 %x, 255
1133 %r = or i1 %cmp, %cmpeq
1137 define i1 @uge_or_max_logical(i8 %x, i8 %y) {
1138 ; CHECK-LABEL: @uge_or_max_logical(
1139 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1140 ; CHECK-NEXT: ret i1 [[CMP]]
1142 %cmp = icmp uge i8 %x, %y
1143 %cmpeq = icmp eq i8 %x, 255
1144 %r = select i1 %cmp, i1 true, i1 %cmpeq
1148 define i1 @uge_or_max_commute(i8 %x, i8 %y) {
1149 ; CHECK-LABEL: @uge_or_max_commute(
1150 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1151 ; CHECK-NEXT: ret i1 [[CMP]]
1153 %cmp = icmp uge i8 %x, %y
1154 %cmpeq = icmp eq i8 %x, 255
1155 %r = or i1 %cmpeq, %cmp
1159 define i1 @uge_or_max_commute_logical(i8 %x, i8 %y) {
1160 ; CHECK-LABEL: @uge_or_max_commute_logical(
1161 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
1162 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1163 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1164 ; CHECK-NEXT: ret i1 [[R]]
1166 %cmp = icmp uge i8 %x, %y
1167 %cmpeq = icmp eq i8 %x, 255
1168 %r = select i1 %cmpeq, i1 true, i1 %cmp
1172 define i1 @uge_swap_or_max(i8 %x, i8 %y) {
1173 ; CHECK-LABEL: @uge_swap_or_max(
1174 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
1175 ; CHECK-NEXT: ret i1 [[CMP]]
1177 %cmp = icmp ule i8 %y, %x
1178 %cmpeq = icmp eq i8 %x, 255
1179 %r = or i1 %cmp, %cmpeq
1183 define i1 @uge_swap_or_max_logical(i8 %x, i8 %y) {
1184 ; CHECK-LABEL: @uge_swap_or_max_logical(
1185 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
1186 ; CHECK-NEXT: ret i1 [[CMP]]
1188 %cmp = icmp ule i8 %y, %x
1189 %cmpeq = icmp eq i8 %x, 255
1190 %r = select i1 %cmp, i1 true, i1 %cmpeq
1194 define i1 @uge_swap_or_max_commute(i8 %x, i8 %y) {
1195 ; CHECK-LABEL: @uge_swap_or_max_commute(
1196 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
1197 ; CHECK-NEXT: ret i1 [[CMP]]
1199 %cmp = icmp ule i8 %y, %x
1200 %cmpeq = icmp eq i8 %x, 255
1201 %r = or i1 %cmpeq, %cmp
1205 define i1 @uge_swap_or_max_commute_logical(i8 %x, i8 %y) {
1206 ; CHECK-LABEL: @uge_swap_or_max_commute_logical(
1207 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
1208 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1209 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1210 ; CHECK-NEXT: ret i1 [[R]]
1212 %cmp = icmp ule i8 %y, %x
1213 %cmpeq = icmp eq i8 %x, 255
1214 %r = select i1 %cmpeq, i1 true, i1 %cmp
1218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1220 ; (X == MIN) || (X <= Y) --> X <= Y
1222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1224 define i1 @sle_or_min(i8 %x, i8 %y) {
1225 ; CHECK-LABEL: @sle_or_min(
1226 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
1227 ; CHECK-NEXT: ret i1 [[CMP]]
1229 %cmp = icmp sle i8 %x, %y
1230 %cmpeq = icmp eq i8 %x, 128
1231 %r = or i1 %cmp, %cmpeq
1235 define i1 @sle_or_min_logical(i8 %x, i8 %y) {
1236 ; CHECK-LABEL: @sle_or_min_logical(
1237 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
1238 ; CHECK-NEXT: ret i1 [[CMP]]
1240 %cmp = icmp sle i8 %x, %y
1241 %cmpeq = icmp eq i8 %x, 128
1242 %r = select i1 %cmp, i1 true, i1 %cmpeq
1246 define i1 @sle_or_min_commute(i8 %x, i8 %y) {
1247 ; CHECK-LABEL: @sle_or_min_commute(
1248 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
1249 ; CHECK-NEXT: ret i1 [[CMP]]
1251 %cmp = icmp sle i8 %x, %y
1252 %cmpeq = icmp eq i8 %x, 128
1253 %r = or i1 %cmpeq, %cmp
1257 define i1 @sle_or_min_commute_logical(i8 %x, i8 %y) {
1258 ; CHECK-LABEL: @sle_or_min_commute_logical(
1259 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
1260 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1261 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1262 ; CHECK-NEXT: ret i1 [[R]]
1264 %cmp = icmp sle i8 %x, %y
1265 %cmpeq = icmp eq i8 %x, 128
1266 %r = select i1 %cmpeq, i1 true, i1 %cmp
1270 define i1 @sle_swap_or_min(i8 %x, i8 %y) {
1271 ; CHECK-LABEL: @sle_swap_or_min(
1272 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
1273 ; CHECK-NEXT: ret i1 [[CMP]]
1275 %cmp = icmp sge i8 %y, %x
1276 %cmpeq = icmp eq i8 %x, 128
1277 %r = or i1 %cmp, %cmpeq
1281 define i1 @sle_swap_or_min_logical(i8 %x, i8 %y) {
1282 ; CHECK-LABEL: @sle_swap_or_min_logical(
1283 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
1284 ; CHECK-NEXT: ret i1 [[CMP]]
1286 %cmp = icmp sge i8 %y, %x
1287 %cmpeq = icmp eq i8 %x, 128
1288 %r = select i1 %cmp, i1 true, i1 %cmpeq
1292 define i1 @sle_swap_or_min_commute(i8 %x, i8 %y) {
1293 ; CHECK-LABEL: @sle_swap_or_min_commute(
1294 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
1295 ; CHECK-NEXT: ret i1 [[CMP]]
1297 %cmp = icmp sge i8 %y, %x
1298 %cmpeq = icmp eq i8 %x, 128
1299 %r = or i1 %cmpeq, %cmp
1303 define i1 @sle_swap_or_min_commute_logical(i8 %x, i8 %y) {
1304 ; CHECK-LABEL: @sle_swap_or_min_commute_logical(
1305 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
1306 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1307 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1308 ; CHECK-NEXT: ret i1 [[R]]
1310 %cmp = icmp sge i8 %y, %x
1311 %cmpeq = icmp eq i8 %x, 128
1312 %r = select i1 %cmpeq, i1 true, i1 %cmp
1316 define i1 @ule_or_min(i8 %x, i8 %y) {
1317 ; CHECK-LABEL: @ule_or_min(
1318 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1319 ; CHECK-NEXT: ret i1 [[CMP]]
1321 %cmp = icmp ule i8 %x, %y
1322 %cmpeq = icmp eq i8 %x, 0
1323 %r = or i1 %cmp, %cmpeq
1327 define i1 @ule_or_min_logical(i8 %x, i8 %y) {
1328 ; CHECK-LABEL: @ule_or_min_logical(
1329 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1330 ; CHECK-NEXT: ret i1 [[CMP]]
1332 %cmp = icmp ule i8 %x, %y
1333 %cmpeq = icmp eq i8 %x, 0
1334 %r = select i1 %cmp, i1 true, i1 %cmpeq
1338 define i1 @ule_or_min_commute(i8 %x, i8 %y) {
1339 ; CHECK-LABEL: @ule_or_min_commute(
1340 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1341 ; CHECK-NEXT: ret i1 [[CMP]]
1343 %cmp = icmp ule i8 %x, %y
1344 %cmpeq = icmp eq i8 %x, 0
1345 %r = or i1 %cmpeq, %cmp
1349 define i1 @ule_or_min_commute_logical(i8 %x, i8 %y) {
1350 ; CHECK-LABEL: @ule_or_min_commute_logical(
1351 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
1352 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1353 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1354 ; CHECK-NEXT: ret i1 [[R]]
1356 %cmp = icmp ule i8 %x, %y
1357 %cmpeq = icmp eq i8 %x, 0
1358 %r = select i1 %cmpeq, i1 true, i1 %cmp
1362 define i1 @ule_swap_or_min(i8 %x, i8 %y) {
1363 ; CHECK-LABEL: @ule_swap_or_min(
1364 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
1365 ; CHECK-NEXT: ret i1 [[CMP]]
1367 %cmp = icmp uge i8 %y, %x
1368 %cmpeq = icmp eq i8 %x, 0
1369 %r = or i1 %cmp, %cmpeq
1373 define i1 @ule_swap_or_min_logical(i8 %x, i8 %y) {
1374 ; CHECK-LABEL: @ule_swap_or_min_logical(
1375 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
1376 ; CHECK-NEXT: ret i1 [[CMP]]
1378 %cmp = icmp uge i8 %y, %x
1379 %cmpeq = icmp eq i8 %x, 0
1380 %r = select i1 %cmp, i1 true, i1 %cmpeq
1384 define i1 @ule_swap_or_min_commute(i8 %x, i8 %y) {
1385 ; CHECK-LABEL: @ule_swap_or_min_commute(
1386 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
1387 ; CHECK-NEXT: ret i1 [[CMP]]
1389 %cmp = icmp uge i8 %y, %x
1390 %cmpeq = icmp eq i8 %x, 0
1391 %r = or i1 %cmpeq, %cmp
1395 define i1 @ule_swap_or_min_commute_logical(i8 %x, i8 %y) {
1396 ; CHECK-LABEL: @ule_swap_or_min_commute_logical(
1397 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
1398 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1399 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
1400 ; CHECK-NEXT: ret i1 [[R]]
1402 %cmp = icmp uge i8 %y, %x
1403 %cmpeq = icmp eq i8 %x, 0
1404 %r = select i1 %cmpeq, i1 true, i1 %cmp
1408 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1410 ; (X != MAX) && (X < Y) --> X < Y
1412 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1414 define i1 @slt_and_not_max(i8 %x, i8 %y) {
1415 ; CHECK-LABEL: @slt_and_not_max(
1416 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1417 ; CHECK-NEXT: ret i1 [[CMP]]
1419 %cmp = icmp slt i8 %x, %y
1420 %cmpeq = icmp ne i8 %x, 127
1421 %r = and i1 %cmp, %cmpeq
1425 define i1 @slt_and_not_max_logical(i8 %x, i8 %y) {
1426 ; CHECK-LABEL: @slt_and_not_max_logical(
1427 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1428 ; CHECK-NEXT: ret i1 [[CMP]]
1430 %cmp = icmp slt i8 %x, %y
1431 %cmpeq = icmp ne i8 %x, 127
1432 %r = select i1 %cmp, i1 %cmpeq, i1 false
1436 define i1 @slt_and_not_max_commute(i8 %x, i8 %y) {
1437 ; CHECK-LABEL: @slt_and_not_max_commute(
1438 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1439 ; CHECK-NEXT: ret i1 [[CMP]]
1441 %cmp = icmp slt i8 %x, %y
1442 %cmpeq = icmp ne i8 %x, 127
1443 %r = and i1 %cmpeq, %cmp
1447 define i1 @slt_and_not_max_commute_logical(i8 %x, i8 %y) {
1448 ; CHECK-LABEL: @slt_and_not_max_commute_logical(
1449 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1450 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1451 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1452 ; CHECK-NEXT: ret i1 [[R]]
1454 %cmp = icmp slt i8 %x, %y
1455 %cmpeq = icmp ne i8 %x, 127
1456 %r = select i1 %cmpeq, i1 %cmp, i1 false
1460 define i1 @slt_swap_and_not_max(i8 %x, i8 %y) {
1461 ; CHECK-LABEL: @slt_swap_and_not_max(
1462 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1463 ; CHECK-NEXT: ret i1 [[CMP]]
1465 %cmp = icmp sgt i8 %y, %x
1466 %cmpeq = icmp ne i8 %x, 127
1467 %r = and i1 %cmp, %cmpeq
1471 define i1 @slt_swap_and_not_max_logical(i8 %x, i8 %y) {
1472 ; CHECK-LABEL: @slt_swap_and_not_max_logical(
1473 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1474 ; CHECK-NEXT: ret i1 [[CMP]]
1476 %cmp = icmp sgt i8 %y, %x
1477 %cmpeq = icmp ne i8 %x, 127
1478 %r = select i1 %cmp, i1 %cmpeq, i1 false
1482 define i1 @slt_swap_and_not_max_commute(i8 %x, i8 %y) {
1483 ; CHECK-LABEL: @slt_swap_and_not_max_commute(
1484 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1485 ; CHECK-NEXT: ret i1 [[CMP]]
1487 %cmp = icmp sgt i8 %y, %x
1488 %cmpeq = icmp ne i8 %x, 127
1489 %r = and i1 %cmpeq, %cmp
1493 define i1 @slt_swap_and_not_max_commute_logical(i8 %x, i8 %y) {
1494 ; CHECK-LABEL: @slt_swap_and_not_max_commute_logical(
1495 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1496 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1497 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1498 ; CHECK-NEXT: ret i1 [[R]]
1500 %cmp = icmp sgt i8 %y, %x
1501 %cmpeq = icmp ne i8 %x, 127
1502 %r = select i1 %cmpeq, i1 %cmp, i1 false
1506 define i1 @ult_and_not_max(i8 %x, i8 %y) {
1507 ; CHECK-LABEL: @ult_and_not_max(
1508 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1509 ; CHECK-NEXT: ret i1 [[CMP]]
1511 %cmp = icmp ult i8 %x, %y
1512 %cmpeq = icmp ne i8 %x, 255
1513 %r = and i1 %cmp, %cmpeq
1517 define i1 @ult_and_not_max_logical(i8 %x, i8 %y) {
1518 ; CHECK-LABEL: @ult_and_not_max_logical(
1519 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1520 ; CHECK-NEXT: ret i1 [[CMP]]
1522 %cmp = icmp ult i8 %x, %y
1523 %cmpeq = icmp ne i8 %x, 255
1524 %r = select i1 %cmp, i1 %cmpeq, i1 false
1528 define i1 @ult_and_not_max_commute(i8 %x, i8 %y) {
1529 ; CHECK-LABEL: @ult_and_not_max_commute(
1530 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1531 ; CHECK-NEXT: ret i1 [[CMP]]
1533 %cmp = icmp ult i8 %x, %y
1534 %cmpeq = icmp ne i8 %x, 255
1535 %r = and i1 %cmpeq, %cmp
1539 define i1 @ult_and_not_max_commute_logical(i8 %x, i8 %y) {
1540 ; CHECK-LABEL: @ult_and_not_max_commute_logical(
1541 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1542 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1543 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1544 ; CHECK-NEXT: ret i1 [[R]]
1546 %cmp = icmp ult i8 %x, %y
1547 %cmpeq = icmp ne i8 %x, 255
1548 %r = select i1 %cmpeq, i1 %cmp, i1 false
1552 define i1 @ult_swap_and_not_max(i8 %x, i8 %y) {
1553 ; CHECK-LABEL: @ult_swap_and_not_max(
1554 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1555 ; CHECK-NEXT: ret i1 [[CMP]]
1557 %cmp = icmp ugt i8 %y, %x
1558 %cmpeq = icmp ne i8 %x, 255
1559 %r = and i1 %cmp, %cmpeq
1563 define i1 @ult_swap_and_not_max_logical(i8 %x, i8 %y) {
1564 ; CHECK-LABEL: @ult_swap_and_not_max_logical(
1565 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1566 ; CHECK-NEXT: ret i1 [[CMP]]
1568 %cmp = icmp ugt i8 %y, %x
1569 %cmpeq = icmp ne i8 %x, 255
1570 %r = select i1 %cmp, i1 %cmpeq, i1 false
1574 define i1 @ult_swap_and_not_max_commute(i8 %x, i8 %y) {
1575 ; CHECK-LABEL: @ult_swap_and_not_max_commute(
1576 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1577 ; CHECK-NEXT: ret i1 [[CMP]]
1579 %cmp = icmp ugt i8 %y, %x
1580 %cmpeq = icmp ne i8 %x, 255
1581 %r = and i1 %cmpeq, %cmp
1585 define i1 @ult_swap_and_not_max_commute_logical(i8 %x, i8 %y) {
1586 ; CHECK-LABEL: @ult_swap_and_not_max_commute_logical(
1587 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1588 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1589 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1590 ; CHECK-NEXT: ret i1 [[R]]
1592 %cmp = icmp ugt i8 %y, %x
1593 %cmpeq = icmp ne i8 %x, 255
1594 %r = select i1 %cmpeq, i1 %cmp, i1 false
1598 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1600 ; (X != MIN) && (X > Y) --> X > Y
1602 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1604 define i1 @sgt_and_not_min(i8 %x, i8 %y) {
1605 ; CHECK-LABEL: @sgt_and_not_min(
1606 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1607 ; CHECK-NEXT: ret i1 [[CMP]]
1609 %cmp = icmp sgt i8 %x, %y
1610 %cmpeq = icmp ne i8 %x, 128
1611 %r = and i1 %cmp, %cmpeq
1615 define i1 @sgt_and_not_min_logical(i8 %x, i8 %y) {
1616 ; CHECK-LABEL: @sgt_and_not_min_logical(
1617 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1618 ; CHECK-NEXT: ret i1 [[CMP]]
1620 %cmp = icmp sgt i8 %x, %y
1621 %cmpeq = icmp ne i8 %x, 128
1622 %r = select i1 %cmp, i1 %cmpeq, i1 false
1626 define i1 @sgt_and_not_min_commute(i8 %x, i8 %y) {
1627 ; CHECK-LABEL: @sgt_and_not_min_commute(
1628 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1629 ; CHECK-NEXT: ret i1 [[CMP]]
1631 %cmp = icmp sgt i8 %x, %y
1632 %cmpeq = icmp ne i8 %x, 128
1633 %r = and i1 %cmpeq, %cmp
1637 define i1 @sgt_and_not_min_commute_logical(i8 %x, i8 %y) {
1638 ; CHECK-LABEL: @sgt_and_not_min_commute_logical(
1639 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1640 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1641 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1642 ; CHECK-NEXT: ret i1 [[R]]
1644 %cmp = icmp sgt i8 %x, %y
1645 %cmpeq = icmp ne i8 %x, 128
1646 %r = select i1 %cmpeq, i1 %cmp, i1 false
1650 define i1 @sgt_swap_and_not_min(i8 %x, i8 %y) {
1651 ; CHECK-LABEL: @sgt_swap_and_not_min(
1652 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1653 ; CHECK-NEXT: ret i1 [[CMP]]
1655 %cmp = icmp slt i8 %y, %x
1656 %cmpeq = icmp ne i8 %x, 128
1657 %r = and i1 %cmp, %cmpeq
1661 define i1 @sgt_swap_and_not_min_logical(i8 %x, i8 %y) {
1662 ; CHECK-LABEL: @sgt_swap_and_not_min_logical(
1663 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1664 ; CHECK-NEXT: ret i1 [[CMP]]
1666 %cmp = icmp slt i8 %y, %x
1667 %cmpeq = icmp ne i8 %x, 128
1668 %r = select i1 %cmp, i1 %cmpeq, i1 false
1672 define i1 @sgt_swap_and_not_min_commute(i8 %x, i8 %y) {
1673 ; CHECK-LABEL: @sgt_swap_and_not_min_commute(
1674 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1675 ; CHECK-NEXT: ret i1 [[CMP]]
1677 %cmp = icmp slt i8 %y, %x
1678 %cmpeq = icmp ne i8 %x, 128
1679 %r = and i1 %cmpeq, %cmp
1683 define i1 @sgt_swap_and_not_min_commute_logical(i8 %x, i8 %y) {
1684 ; CHECK-LABEL: @sgt_swap_and_not_min_commute_logical(
1685 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1686 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1687 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1688 ; CHECK-NEXT: ret i1 [[R]]
1690 %cmp = icmp slt i8 %y, %x
1691 %cmpeq = icmp ne i8 %x, 128
1692 %r = select i1 %cmpeq, i1 %cmp, i1 false
1696 define i1 @ugt_and_not_min(i8 %x, i8 %y) {
1697 ; CHECK-LABEL: @ugt_and_not_min(
1698 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1699 ; CHECK-NEXT: ret i1 [[CMP]]
1701 %cmp = icmp ugt i8 %x, %y
1702 %cmpeq = icmp ne i8 %x, 0
1703 %r = and i1 %cmp, %cmpeq
1707 define i1 @ugt_and_not_min_logical(i8 %x, i8 %y) {
1708 ; CHECK-LABEL: @ugt_and_not_min_logical(
1709 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1710 ; CHECK-NEXT: ret i1 [[CMP]]
1712 %cmp = icmp ugt i8 %x, %y
1713 %cmpeq = icmp ne i8 %x, 0
1714 %r = select i1 %cmp, i1 %cmpeq, i1 false
1718 define i1 @ugt_and_not_min_commute(i8 %x, i8 %y) {
1719 ; CHECK-LABEL: @ugt_and_not_min_commute(
1720 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1721 ; CHECK-NEXT: ret i1 [[CMP]]
1723 %cmp = icmp ugt i8 %x, %y
1724 %cmpeq = icmp ne i8 %x, 0
1725 %r = and i1 %cmpeq, %cmp
1729 define i1 @ugt_and_not_min_commute_logical(i8 %x, i8 %y) {
1730 ; CHECK-LABEL: @ugt_and_not_min_commute_logical(
1731 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
1732 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1733 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1734 ; CHECK-NEXT: ret i1 [[R]]
1736 %cmp = icmp ugt i8 %x, %y
1737 %cmpeq = icmp ne i8 %x, 0
1738 %r = select i1 %cmpeq, i1 %cmp, i1 false
1742 define i1 @ugt_swap_and_not_min(i8 %x, i8 %y) {
1743 ; CHECK-LABEL: @ugt_swap_and_not_min(
1744 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
1745 ; CHECK-NEXT: ret i1 [[CMP]]
1747 %cmp = icmp ult i8 %y, %x
1748 %cmpeq = icmp ne i8 %x, 0
1749 %r = and i1 %cmp, %cmpeq
1753 define i1 @ugt_swap_and_not_min_logical(i8 %x, i8 %y) {
1754 ; CHECK-LABEL: @ugt_swap_and_not_min_logical(
1755 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
1756 ; CHECK-NEXT: ret i1 [[CMP]]
1758 %cmp = icmp ult i8 %y, %x
1759 %cmpeq = icmp ne i8 %x, 0
1760 %r = select i1 %cmp, i1 %cmpeq, i1 false
1764 define i1 @ugt_swap_and_not_min_commute(i8 %x, i8 %y) {
1765 ; CHECK-LABEL: @ugt_swap_and_not_min_commute(
1766 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
1767 ; CHECK-NEXT: ret i1 [[CMP]]
1769 %cmp = icmp ult i8 %y, %x
1770 %cmpeq = icmp ne i8 %x, 0
1771 %r = and i1 %cmpeq, %cmp
1775 define i1 @ugt_swap_and_not_min_commute_logical(i8 %x, i8 %y) {
1776 ; CHECK-LABEL: @ugt_swap_and_not_min_commute_logical(
1777 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
1778 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1779 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
1780 ; CHECK-NEXT: ret i1 [[R]]
1782 %cmp = icmp ult i8 %y, %x
1783 %cmpeq = icmp ne i8 %x, 0
1784 %r = select i1 %cmpeq, i1 %cmp, i1 false
1788 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1790 ; (X != MAX) || (X < Y) --> X != MAX
1792 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1794 define i1 @slt_or_not_max(i8 %x, i8 %y) {
1795 ; CHECK-LABEL: @slt_or_not_max(
1796 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1797 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1799 %cmp = icmp slt i8 %x, %y
1800 %cmpeq = icmp ne i8 %x, 127
1801 %r = or i1 %cmp, %cmpeq
1805 define i1 @slt_or_not_max_logical(i8 %x, i8 %y) {
1806 ; CHECK-LABEL: @slt_or_not_max_logical(
1807 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1808 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1810 %cmp = icmp slt i8 %x, %y
1811 %cmpeq = icmp ne i8 %x, 127
1812 %r = select i1 %cmp, i1 true, i1 %cmpeq
1816 define i1 @slt_or_not_max_commute(i8 %x, i8 %y) {
1817 ; CHECK-LABEL: @slt_or_not_max_commute(
1818 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1819 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1821 %cmp = icmp slt i8 %x, %y
1822 %cmpeq = icmp ne i8 %x, 127
1823 %r = or i1 %cmpeq, %cmp
1827 define i1 @slt_or_not_max_commute_logical(i8 %x, i8 %y) {
1828 ; CHECK-LABEL: @slt_or_not_max_commute_logical(
1829 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1830 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1832 %cmp = icmp slt i8 %x, %y
1833 %cmpeq = icmp ne i8 %x, 127
1834 %r = select i1 %cmpeq, i1 true, i1 %cmp
1838 define i1 @slt_swap_or_not_max(i8 %x, i8 %y) {
1839 ; CHECK-LABEL: @slt_swap_or_not_max(
1840 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1841 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1843 %cmp = icmp sgt i8 %y, %x
1844 %cmpeq = icmp ne i8 %x, 127
1845 %r = or i1 %cmp, %cmpeq
1849 define i1 @slt_swap_or_not_max_logical(i8 %x, i8 %y) {
1850 ; CHECK-LABEL: @slt_swap_or_not_max_logical(
1851 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1852 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1854 %cmp = icmp sgt i8 %y, %x
1855 %cmpeq = icmp ne i8 %x, 127
1856 %r = select i1 %cmp, i1 true, i1 %cmpeq
1860 define i1 @slt_swap_or_not_max_commute(i8 %x, i8 %y) {
1861 ; CHECK-LABEL: @slt_swap_or_not_max_commute(
1862 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1863 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1865 %cmp = icmp sgt i8 %y, %x
1866 %cmpeq = icmp ne i8 %x, 127
1867 %r = or i1 %cmpeq, %cmp
1871 define i1 @slt_swap_or_not_max_commute_logical(i8 %x, i8 %y) {
1872 ; CHECK-LABEL: @slt_swap_or_not_max_commute_logical(
1873 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 127
1874 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1876 %cmp = icmp sgt i8 %y, %x
1877 %cmpeq = icmp ne i8 %x, 127
1878 %r = select i1 %cmpeq, i1 true, i1 %cmp
1882 define i1 @ult_or_not_max(i8 %x, i8 %y) {
1883 ; CHECK-LABEL: @ult_or_not_max(
1884 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1885 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1887 %cmp = icmp ult i8 %x, %y
1888 %cmpeq = icmp ne i8 %x, 255
1889 %r = or i1 %cmp, %cmpeq
1893 define i1 @ult_or_not_max_logical(i8 %x, i8 %y) {
1894 ; CHECK-LABEL: @ult_or_not_max_logical(
1895 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1896 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1898 %cmp = icmp ult i8 %x, %y
1899 %cmpeq = icmp ne i8 %x, 255
1900 %r = select i1 %cmp, i1 true, i1 %cmpeq
1904 define i1 @ult_or_not_max_commute(i8 %x, i8 %y) {
1905 ; CHECK-LABEL: @ult_or_not_max_commute(
1906 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1907 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1909 %cmp = icmp ult i8 %x, %y
1910 %cmpeq = icmp ne i8 %x, 255
1911 %r = or i1 %cmpeq, %cmp
1915 define i1 @ult_or_not_max_commute_logical(i8 %x, i8 %y) {
1916 ; CHECK-LABEL: @ult_or_not_max_commute_logical(
1917 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1918 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1920 %cmp = icmp ult i8 %x, %y
1921 %cmpeq = icmp ne i8 %x, 255
1922 %r = select i1 %cmpeq, i1 true, i1 %cmp
1926 define i1 @ult_swap_or_not_max(i8 %x, i8 %y) {
1927 ; CHECK-LABEL: @ult_swap_or_not_max(
1928 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1929 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1931 %cmp = icmp ugt i8 %y, %x
1932 %cmpeq = icmp ne i8 %x, 255
1933 %r = or i1 %cmp, %cmpeq
1937 define i1 @ult_swap_or_not_max_logical(i8 %x, i8 %y) {
1938 ; CHECK-LABEL: @ult_swap_or_not_max_logical(
1939 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1940 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1942 %cmp = icmp ugt i8 %y, %x
1943 %cmpeq = icmp ne i8 %x, 255
1944 %r = select i1 %cmp, i1 true, i1 %cmpeq
1948 define i1 @ult_swap_or_not_max_commute(i8 %x, i8 %y) {
1949 ; CHECK-LABEL: @ult_swap_or_not_max_commute(
1950 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1951 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1953 %cmp = icmp ugt i8 %y, %x
1954 %cmpeq = icmp ne i8 %x, 255
1955 %r = or i1 %cmpeq, %cmp
1959 define i1 @ult_swap_or_not_max_commute_logical(i8 %x, i8 %y) {
1960 ; CHECK-LABEL: @ult_swap_or_not_max_commute_logical(
1961 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -1
1962 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1964 %cmp = icmp ugt i8 %y, %x
1965 %cmpeq = icmp ne i8 %x, 255
1966 %r = select i1 %cmpeq, i1 true, i1 %cmp
1970 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1972 ; (X != MIN) || (X > Y) --> X != MIN
1974 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1976 define i1 @sgt_or_not_min(i8 %x, i8 %y) {
1977 ; CHECK-LABEL: @sgt_or_not_min(
1978 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
1979 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1981 %cmp = icmp sgt i8 %x, %y
1982 %cmpeq = icmp ne i8 %x, 128
1983 %r = or i1 %cmp, %cmpeq
1987 define i1 @sgt_or_not_min_logical(i8 %x, i8 %y) {
1988 ; CHECK-LABEL: @sgt_or_not_min_logical(
1989 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
1990 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1992 %cmp = icmp sgt i8 %x, %y
1993 %cmpeq = icmp ne i8 %x, 128
1994 %r = select i1 %cmp, i1 true, i1 %cmpeq
1998 define i1 @sgt_or_not_min_commute(i8 %x, i8 %y) {
1999 ; CHECK-LABEL: @sgt_or_not_min_commute(
2000 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2001 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2003 %cmp = icmp sgt i8 %x, %y
2004 %cmpeq = icmp ne i8 %x, 128
2005 %r = or i1 %cmpeq, %cmp
2009 define i1 @sgt_or_not_min_commute_logical(i8 %x, i8 %y) {
2010 ; CHECK-LABEL: @sgt_or_not_min_commute_logical(
2011 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2012 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2014 %cmp = icmp sgt i8 %x, %y
2015 %cmpeq = icmp ne i8 %x, 128
2016 %r = select i1 %cmpeq, i1 true, i1 %cmp
2020 define i1 @sgt_swap_or_not_min(i8 %x, i8 %y) {
2021 ; CHECK-LABEL: @sgt_swap_or_not_min(
2022 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2023 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2025 %cmp = icmp slt i8 %y, %x
2026 %cmpeq = icmp ne i8 %x, 128
2027 %r = or i1 %cmp, %cmpeq
2031 define i1 @sgt_swap_or_not_min_logical(i8 %x, i8 %y) {
2032 ; CHECK-LABEL: @sgt_swap_or_not_min_logical(
2033 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2034 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2036 %cmp = icmp slt i8 %y, %x
2037 %cmpeq = icmp ne i8 %x, 128
2038 %r = select i1 %cmp, i1 true, i1 %cmpeq
2042 define i1 @sgt_swap_or_not_min_commute(i8 %x, i8 %y) {
2043 ; CHECK-LABEL: @sgt_swap_or_not_min_commute(
2044 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2045 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2047 %cmp = icmp slt i8 %y, %x
2048 %cmpeq = icmp ne i8 %x, 128
2049 %r = or i1 %cmpeq, %cmp
2053 define i1 @sgt_swap_or_not_min_commute_logical(i8 %x, i8 %y) {
2054 ; CHECK-LABEL: @sgt_swap_or_not_min_commute_logical(
2055 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], -128
2056 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2058 %cmp = icmp slt i8 %y, %x
2059 %cmpeq = icmp ne i8 %x, 128
2060 %r = select i1 %cmpeq, i1 true, i1 %cmp
2064 define i1 @ugt_or_not_min(i8 %x, i8 %y) {
2065 ; CHECK-LABEL: @ugt_or_not_min(
2066 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2067 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2069 %cmp = icmp ugt i8 %x, %y
2070 %cmpeq = icmp ne i8 %x, 0
2071 %r = or i1 %cmp, %cmpeq
2075 define i1 @ugt_or_not_min_logical(i8 %x, i8 %y) {
2076 ; CHECK-LABEL: @ugt_or_not_min_logical(
2077 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2078 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2080 %cmp = icmp ugt i8 %x, %y
2081 %cmpeq = icmp ne i8 %x, 0
2082 %r = select i1 %cmp, i1 true, i1 %cmpeq
2086 define i1 @ugt_or_not_min_commute(i8 %x, i8 %y) {
2087 ; CHECK-LABEL: @ugt_or_not_min_commute(
2088 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2089 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2091 %cmp = icmp ugt i8 %x, %y
2092 %cmpeq = icmp ne i8 %x, 0
2093 %r = or i1 %cmpeq, %cmp
2097 define i1 @ugt_or_not_min_commute_logical(i8 %x, i8 %y) {
2098 ; CHECK-LABEL: @ugt_or_not_min_commute_logical(
2099 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2100 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2102 %cmp = icmp ugt i8 %x, %y
2103 %cmpeq = icmp ne i8 %x, 0
2104 %r = select i1 %cmpeq, i1 true, i1 %cmp
2108 define i1 @ugt_swap_or_not_min(i8 %x, i8 %y) {
2109 ; CHECK-LABEL: @ugt_swap_or_not_min(
2110 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2111 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2113 %cmp = icmp ult i8 %y, %x
2114 %cmpeq = icmp ne i8 %x, 0
2115 %r = or i1 %cmp, %cmpeq
2119 define i1 @ugt_swap_or_not_min_logical(i8 %x, i8 %y) {
2120 ; CHECK-LABEL: @ugt_swap_or_not_min_logical(
2121 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
2122 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2124 %cmp = icmp ult i8 %y, %x
2125 %cmpeq = icmp ne i8 %x, 0
2126 %r = select i1 %cmp, i1 true, i1 %cmpeq
2130 define i1 @ugt_swap_or_not_min_commute(i823 %x, i823 %y) {
2131 ; CHECK-LABEL: @ugt_swap_or_not_min_commute(
2132 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823 [[X:%.*]], 0
2133 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2135 %cmp = icmp ult i823 %y, %x
2136 %cmpeq = icmp ne i823 %x, 0
2137 %r = or i1 %cmpeq, %cmp
2141 define i1 @ugt_swap_or_not_min_commute_logical(i823 %x, i823 %y) {
2142 ; CHECK-LABEL: @ugt_swap_or_not_min_commute_logical(
2143 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823 [[X:%.*]], 0
2144 ; CHECK-NEXT: ret i1 [[CMPEQ]]
2146 %cmp = icmp ult i823 %y, %x
2147 %cmpeq = icmp ne i823 %x, 0
2148 %r = select i1 %cmpeq, i1 true, i1 %cmp