1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -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) *
7 ; 2 (signed/unsigned) *
8 ; 2 (not of input operand)
9 ; variations for a total of 192 tests.
11 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13 ; (X == MAX) && (X < Y) --> false
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17 define i1 @slt_and_max(i8 %x, i8 %y) {
18 ; CHECK-LABEL: @slt_and_max(
19 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
20 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
21 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
22 ; CHECK-NEXT: ret i1 [[R]]
24 %cmp = icmp slt i8 %x, %y
25 %cmpeq = icmp eq i8 %x, 127
26 %r = and i1 %cmp, %cmpeq
30 define <2 x i1> @slt_and_max_commute(<2 x i8> %x, <2 x i8> %y) {
31 ; CHECK-LABEL: @slt_and_max_commute(
32 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[X:%.*]], [[Y:%.*]]
33 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq <2 x i8> [[X]], <i8 127, i8 127>
34 ; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[CMPEQ]], [[CMP]]
35 ; CHECK-NEXT: ret <2 x i1> [[R]]
37 %cmp = icmp slt <2 x i8> %x, %y
38 %cmpeq = icmp eq <2 x i8> %x, <i8 127, i8 127>
39 %r = and <2 x i1> %cmpeq, %cmp
43 define i1 @slt_swap_and_max(i8 %x, i8 %y) {
44 ; CHECK-LABEL: @slt_swap_and_max(
45 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
46 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
47 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
48 ; CHECK-NEXT: ret i1 [[R]]
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_commute(i8 %x, i8 %y) {
57 ; CHECK-LABEL: @slt_swap_and_max_commute(
58 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
59 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
60 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
61 ; CHECK-NEXT: ret i1 [[R]]
63 %cmp = icmp sgt i8 %y, %x
64 %cmpeq = icmp eq i8 %x, 127
65 %r = and i1 %cmpeq, %cmp
69 define i1 @ult_and_max(i8 %x, i8 %y) {
70 ; CHECK-LABEL: @ult_and_max(
71 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
72 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
73 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
74 ; CHECK-NEXT: ret i1 [[R]]
76 %cmp = icmp ult i8 %x, %y
77 %cmpeq = icmp eq i8 %x, 255
78 %r = and i1 %cmp, %cmpeq
82 define i1 @ult_and_max_commute(i8 %x, i8 %y) {
83 ; CHECK-LABEL: @ult_and_max_commute(
84 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
85 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
86 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
87 ; CHECK-NEXT: ret i1 [[R]]
89 %cmp = icmp ult i8 %x, %y
90 %cmpeq = icmp eq i8 %x, 255
91 %r = and i1 %cmpeq, %cmp
95 define i1 @ult_swap_and_max(i8 %x, i8 %y) {
96 ; CHECK-LABEL: @ult_swap_and_max(
97 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
98 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
99 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
100 ; CHECK-NEXT: ret i1 [[R]]
102 %cmp = icmp ugt i8 %y, %x
103 %cmpeq = icmp eq i8 %x, 255
104 %r = and i1 %cmp, %cmpeq
108 define i1 @ult_swap_and_max_commute(i8 %x, i8 %y) {
109 ; CHECK-LABEL: @ult_swap_and_max_commute(
110 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
111 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
112 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
113 ; CHECK-NEXT: ret i1 [[R]]
115 %cmp = icmp ugt i8 %y, %x
116 %cmpeq = icmp eq i8 %x, 255
117 %r = and i1 %cmpeq, %cmp
121 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
123 ; (X == MIN) && (X > Y) --> false
125 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
127 define i1 @sgt_and_min(i9 %x, i9 %y) {
128 ; CHECK-LABEL: @sgt_and_min(
129 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i9 [[X:%.*]], [[Y:%.*]]
130 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i9 [[X]], -256
131 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
132 ; CHECK-NEXT: ret i1 [[R]]
134 %cmp = icmp sgt i9 %x, %y
135 %cmpeq = icmp eq i9 %x, 256
136 %r = and i1 %cmp, %cmpeq
140 define i1 @sgt_and_min_commute(i8 %x, i8 %y) {
141 ; CHECK-LABEL: @sgt_and_min_commute(
142 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
143 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
144 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
145 ; CHECK-NEXT: ret i1 [[R]]
147 %cmp = icmp sgt i8 %x, %y
148 %cmpeq = icmp eq i8 %x, 128
149 %r = and i1 %cmpeq, %cmp
153 define i1 @sgt_swap_and_min(i8 %x, i8 %y) {
154 ; CHECK-LABEL: @sgt_swap_and_min(
155 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
156 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
157 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
158 ; CHECK-NEXT: ret i1 [[R]]
160 %cmp = icmp slt i8 %y, %x
161 %cmpeq = icmp eq i8 %x, 128
162 %r = and i1 %cmp, %cmpeq
166 define i1 @sgt_swap_and_min_commute(i8 %x, i8 %y) {
167 ; CHECK-LABEL: @sgt_swap_and_min_commute(
168 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
169 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
170 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
171 ; CHECK-NEXT: ret i1 [[R]]
173 %cmp = icmp slt i8 %y, %x
174 %cmpeq = icmp eq i8 %x, 128
175 %r = and i1 %cmpeq, %cmp
179 define i1 @ugt_and_min(i8 %x, i8 %y) {
180 ; CHECK-LABEL: @ugt_and_min(
181 ; CHECK-NEXT: ret i1 false
183 %cmp = icmp ugt i8 %x, %y
184 %cmpeq = icmp eq i8 %x, 0
185 %r = and i1 %cmp, %cmpeq
189 define i1 @ugt_and_min_commute(i8 %x, i8 %y) {
190 ; CHECK-LABEL: @ugt_and_min_commute(
191 ; CHECK-NEXT: ret i1 false
193 %cmp = icmp ugt i8 %x, %y
194 %cmpeq = icmp eq i8 %x, 0
195 %r = and i1 %cmpeq, %cmp
199 define i1 @ugt_swap_and_min(i8 %x, i8 %y) {
200 ; CHECK-LABEL: @ugt_swap_and_min(
201 ; CHECK-NEXT: ret i1 false
203 %cmp = icmp ult i8 %y, %x
204 %cmpeq = icmp eq i8 %x, 0
205 %r = and i1 %cmp, %cmpeq
209 define i1 @ugt_swap_and_min_commute(i8 %x, i8 %y) {
210 ; CHECK-LABEL: @ugt_swap_and_min_commute(
211 ; CHECK-NEXT: ret i1 false
213 %cmp = icmp ult i8 %y, %x
214 %cmpeq = icmp eq i8 %x, 0
215 %r = and i1 %cmpeq, %cmp
219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
221 ; (X != MAX) || (X >= Y) --> true
223 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
225 define i1 @sge_or_not_max(i8 %x, i8 %y) {
226 ; CHECK-LABEL: @sge_or_not_max(
227 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
228 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
229 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
230 ; CHECK-NEXT: ret i1 [[R]]
232 %cmp = icmp sge i8 %x, %y
233 %cmpeq = icmp ne i8 %x, 127
234 %r = or i1 %cmp, %cmpeq
238 define i1 @sge_or_not_max_commute(i8 %x, i8 %y) {
239 ; CHECK-LABEL: @sge_or_not_max_commute(
240 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
241 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
242 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
243 ; CHECK-NEXT: ret i1 [[R]]
245 %cmp = icmp sge i8 %x, %y
246 %cmpeq = icmp ne i8 %x, 127
247 %r = or i1 %cmpeq, %cmp
251 define i1 @sge_swap_or_not_max(i8 %x, i8 %y) {
252 ; CHECK-LABEL: @sge_swap_or_not_max(
253 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
254 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
255 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
256 ; CHECK-NEXT: ret i1 [[R]]
258 %cmp = icmp sle i8 %y, %x
259 %cmpeq = icmp ne i8 %x, 127
260 %r = or i1 %cmp, %cmpeq
264 define i1 @sge_swap_or_not_max_commute(i8 %x, i8 %y) {
265 ; CHECK-LABEL: @sge_swap_or_not_max_commute(
266 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
267 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
268 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
269 ; CHECK-NEXT: ret i1 [[R]]
271 %cmp = icmp sle i8 %y, %x
272 %cmpeq = icmp ne i8 %x, 127
273 %r = or i1 %cmpeq, %cmp
277 define i1 @uge_or_not_max(i8 %x, i8 %y) {
278 ; CHECK-LABEL: @uge_or_not_max(
279 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
280 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
281 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
282 ; CHECK-NEXT: ret i1 [[R]]
284 %cmp = icmp uge i8 %x, %y
285 %cmpeq = icmp ne i8 %x, 255
286 %r = or i1 %cmp, %cmpeq
290 define i1 @uge_or_not_max_commute(i8 %x, i8 %y) {
291 ; CHECK-LABEL: @uge_or_not_max_commute(
292 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
293 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
294 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
295 ; CHECK-NEXT: ret i1 [[R]]
297 %cmp = icmp uge i8 %x, %y
298 %cmpeq = icmp ne i8 %x, 255
299 %r = or i1 %cmpeq, %cmp
303 define i1 @uge_swap_or_not_max(i8 %x, i8 %y) {
304 ; CHECK-LABEL: @uge_swap_or_not_max(
305 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
306 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
307 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
308 ; CHECK-NEXT: ret i1 [[R]]
310 %cmp = icmp ule i8 %y, %x
311 %cmpeq = icmp ne i8 %x, 255
312 %r = or i1 %cmp, %cmpeq
316 define i1 @uge_swap_or_not_max_commute(i8 %x, i8 %y) {
317 ; CHECK-LABEL: @uge_swap_or_not_max_commute(
318 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
319 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
320 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
321 ; CHECK-NEXT: ret i1 [[R]]
323 %cmp = icmp ule i8 %y, %x
324 %cmpeq = icmp ne i8 %x, 255
325 %r = or i1 %cmpeq, %cmp
329 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
331 ; (X != MIN) || (X <= Y) --> true
333 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
335 define i1 @sle_or_not_min(i8 %x, i8 %y) {
336 ; CHECK-LABEL: @sle_or_not_min(
337 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
338 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
339 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
340 ; CHECK-NEXT: ret i1 [[R]]
342 %cmp = icmp sle i8 %x, %y
343 %cmpeq = icmp ne i8 %x, 128
344 %r = or i1 %cmp, %cmpeq
348 define i1 @sle_or_not_min_commute(i8 %x, i8 %y) {
349 ; CHECK-LABEL: @sle_or_not_min_commute(
350 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
351 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
352 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
353 ; CHECK-NEXT: ret i1 [[R]]
355 %cmp = icmp sle i8 %x, %y
356 %cmpeq = icmp ne i8 %x, 128
357 %r = or i1 %cmpeq, %cmp
361 define i1 @sle_swap_or_not_min(i8 %x, i8 %y) {
362 ; CHECK-LABEL: @sle_swap_or_not_min(
363 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
364 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
365 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
366 ; CHECK-NEXT: ret i1 [[R]]
368 %cmp = icmp sge i8 %y, %x
369 %cmpeq = icmp ne i8 %x, 128
370 %r = or i1 %cmp, %cmpeq
374 define i1 @sle_swap_or_not_min_commute(i8 %x, i8 %y) {
375 ; CHECK-LABEL: @sle_swap_or_not_min_commute(
376 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
377 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
378 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
379 ; CHECK-NEXT: ret i1 [[R]]
381 %cmp = icmp sge i8 %y, %x
382 %cmpeq = icmp ne i8 %x, 128
383 %r = or i1 %cmpeq, %cmp
387 define i1 @ule_or_not_min(i427 %x, i427 %y) {
388 ; CHECK-LABEL: @ule_or_not_min(
389 ; CHECK-NEXT: ret i1 true
391 %cmp = icmp ule i427 %x, %y
392 %cmpeq = icmp ne i427 %x, 0
393 %r = or i1 %cmp, %cmpeq
397 define i1 @ule_or_not_min_commute(i8 %x, i8 %y) {
398 ; CHECK-LABEL: @ule_or_not_min_commute(
399 ; CHECK-NEXT: ret i1 true
401 %cmp = icmp ule i8 %x, %y
402 %cmpeq = icmp ne i8 %x, 0
403 %r = or i1 %cmpeq, %cmp
407 define i1 @ule_swap_or_not_min(i8 %x, i8 %y) {
408 ; CHECK-LABEL: @ule_swap_or_not_min(
409 ; CHECK-NEXT: ret i1 true
411 %cmp = icmp uge i8 %y, %x
412 %cmpeq = icmp ne i8 %x, 0
413 %r = or i1 %cmp, %cmpeq
417 define i1 @ule_swap_or_not_min_commute(i8 %x, i8 %y) {
418 ; CHECK-LABEL: @ule_swap_or_not_min_commute(
419 ; CHECK-NEXT: ret i1 true
421 %cmp = icmp uge i8 %y, %x
422 %cmpeq = icmp ne i8 %x, 0
423 %r = or i1 %cmpeq, %cmp
427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
429 ; (X == MAX) && (X >= Y) --> X == MAX
431 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
433 define i1 @sge_and_max(i8 %x, i8 %y) {
434 ; CHECK-LABEL: @sge_and_max(
435 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
436 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
437 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
438 ; CHECK-NEXT: ret i1 [[R]]
440 %cmp = icmp sge i8 %x, %y
441 %cmpeq = icmp eq i8 %x, 127
442 %r = and i1 %cmp, %cmpeq
446 define i1 @sge_and_max_commute(i8 %x, i8 %y) {
447 ; CHECK-LABEL: @sge_and_max_commute(
448 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
449 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
450 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
451 ; CHECK-NEXT: ret i1 [[R]]
453 %cmp = icmp sge i8 %x, %y
454 %cmpeq = icmp eq i8 %x, 127
455 %r = and i1 %cmpeq, %cmp
459 define i1 @sge_swap_and_max(i8 %x, i8 %y) {
460 ; CHECK-LABEL: @sge_swap_and_max(
461 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
462 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
463 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
464 ; CHECK-NEXT: ret i1 [[R]]
466 %cmp = icmp sle i8 %y, %x
467 %cmpeq = icmp eq i8 %x, 127
468 %r = and i1 %cmp, %cmpeq
472 define i1 @sge_swap_and_max_commute(i8 %x, i8 %y) {
473 ; CHECK-LABEL: @sge_swap_and_max_commute(
474 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
475 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
476 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
477 ; CHECK-NEXT: ret i1 [[R]]
479 %cmp = icmp sle i8 %y, %x
480 %cmpeq = icmp eq i8 %x, 127
481 %r = and i1 %cmpeq, %cmp
485 define i1 @uge_and_max(i8 %x, i8 %y) {
486 ; CHECK-LABEL: @uge_and_max(
487 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
488 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
489 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
490 ; CHECK-NEXT: ret i1 [[R]]
492 %cmp = icmp uge i8 %x, %y
493 %cmpeq = icmp eq i8 %x, 255
494 %r = and i1 %cmp, %cmpeq
498 define i1 @uge_and_max_commute(i8 %x, i8 %y) {
499 ; CHECK-LABEL: @uge_and_max_commute(
500 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
501 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
502 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
503 ; CHECK-NEXT: ret i1 [[R]]
505 %cmp = icmp uge i8 %x, %y
506 %cmpeq = icmp eq i8 %x, 255
507 %r = and i1 %cmpeq, %cmp
511 define i1 @uge_swap_and_max(i8 %x, i8 %y) {
512 ; CHECK-LABEL: @uge_swap_and_max(
513 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
514 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
515 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
516 ; CHECK-NEXT: ret i1 [[R]]
518 %cmp = icmp ule i8 %y, %x
519 %cmpeq = icmp eq i8 %x, 255
520 %r = and i1 %cmp, %cmpeq
524 define i1 @uge_swap_and_max_commute(i8 %x, i8 %y) {
525 ; CHECK-LABEL: @uge_swap_and_max_commute(
526 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
527 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
528 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
529 ; CHECK-NEXT: ret i1 [[R]]
531 %cmp = icmp ule i8 %y, %x
532 %cmpeq = icmp eq i8 %x, 255
533 %r = and i1 %cmpeq, %cmp
537 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
539 ; (X == MIN) && (X <= Y) --> X == MIN
541 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
543 define i1 @sle_and_min(i8 %x, i8 %y) {
544 ; CHECK-LABEL: @sle_and_min(
545 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
546 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
547 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
548 ; CHECK-NEXT: ret i1 [[R]]
550 %cmp = icmp sle i8 %x, %y
551 %cmpeq = icmp eq i8 %x, 128
552 %r = and i1 %cmp, %cmpeq
556 define i1 @sle_and_min_commute(i8 %x, i8 %y) {
557 ; CHECK-LABEL: @sle_and_min_commute(
558 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
559 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
560 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
561 ; CHECK-NEXT: ret i1 [[R]]
563 %cmp = icmp sle i8 %x, %y
564 %cmpeq = icmp eq i8 %x, 128
565 %r = and i1 %cmpeq, %cmp
569 define i1 @sle_swap_and_min(i8 %x, i8 %y) {
570 ; CHECK-LABEL: @sle_swap_and_min(
571 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
572 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
573 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
574 ; CHECK-NEXT: ret i1 [[R]]
576 %cmp = icmp sge i8 %y, %x
577 %cmpeq = icmp eq i8 %x, 128
578 %r = and i1 %cmp, %cmpeq
582 define i1 @sle_swap_and_min_commute(i8 %x, i8 %y) {
583 ; CHECK-LABEL: @sle_swap_and_min_commute(
584 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
585 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
586 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
587 ; CHECK-NEXT: ret i1 [[R]]
589 %cmp = icmp sge i8 %y, %x
590 %cmpeq = icmp eq i8 %x, 128
591 %r = and i1 %cmpeq, %cmp
595 define i1 @ule_and_min(i8 %x, i8 %y) {
596 ; CHECK-LABEL: @ule_and_min(
597 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
598 ; CHECK-NEXT: ret i1 [[CMPEQ]]
600 %cmp = icmp ule i8 %x, %y
601 %cmpeq = icmp eq i8 %x, 0
602 %r = and i1 %cmp, %cmpeq
606 define i1 @ule_and_min_commute(i8 %x, i8 %y) {
607 ; CHECK-LABEL: @ule_and_min_commute(
608 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
609 ; CHECK-NEXT: ret i1 [[CMPEQ]]
611 %cmp = icmp ule i8 %x, %y
612 %cmpeq = icmp eq i8 %x, 0
613 %r = and i1 %cmpeq, %cmp
617 define i1 @ule_swap_and_min(i8 %x, i8 %y) {
618 ; CHECK-LABEL: @ule_swap_and_min(
619 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
620 ; CHECK-NEXT: ret i1 [[CMPEQ]]
622 %cmp = icmp uge i8 %y, %x
623 %cmpeq = icmp eq i8 %x, 0
624 %r = and i1 %cmp, %cmpeq
628 define i1 @ule_swap_and_min_commute(i8 %x, i8 %y) {
629 ; CHECK-LABEL: @ule_swap_and_min_commute(
630 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X:%.*]], 0
631 ; CHECK-NEXT: ret i1 [[CMPEQ]]
633 %cmp = icmp uge i8 %y, %x
634 %cmpeq = icmp eq i8 %x, 0
635 %r = and i1 %cmpeq, %cmp
639 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
641 ; (X == MAX) || (X >= Y) --> X >= Y
643 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
645 define i1 @sge_or_max(i8 %x, i8 %y) {
646 ; CHECK-LABEL: @sge_or_max(
647 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
648 ; CHECK-NEXT: ret i1 [[CMP]]
650 %cmp = icmp sge i8 %x, %y
651 %cmpeq = icmp eq i8 %x, 127
652 %r = or i1 %cmp, %cmpeq
656 define i1 @sge_or_max_commute(i8 %x, i8 %y) {
657 ; CHECK-LABEL: @sge_or_max_commute(
658 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[X:%.*]], [[Y:%.*]]
659 ; CHECK-NEXT: ret i1 [[CMP]]
661 %cmp = icmp sge i8 %x, %y
662 %cmpeq = icmp eq i8 %x, 127
663 %r = or i1 %cmpeq, %cmp
667 define i1 @sge_swap_or_max(i8 %x, i8 %y) {
668 ; CHECK-LABEL: @sge_swap_or_max(
669 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
670 ; CHECK-NEXT: ret i1 [[CMP]]
672 %cmp = icmp sle i8 %y, %x
673 %cmpeq = icmp eq i8 %x, 127
674 %r = or i1 %cmp, %cmpeq
678 define i1 @sge_swap_or_max_commute(i8 %x, i8 %y) {
679 ; CHECK-LABEL: @sge_swap_or_max_commute(
680 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[X:%.*]]
681 ; CHECK-NEXT: ret i1 [[CMP]]
683 %cmp = icmp sle i8 %y, %x
684 %cmpeq = icmp eq i8 %x, 127
685 %r = or i1 %cmpeq, %cmp
689 define i1 @uge_or_max(i8 %x, i8 %y) {
690 ; CHECK-LABEL: @uge_or_max(
691 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
692 ; CHECK-NEXT: ret i1 [[CMP]]
694 %cmp = icmp uge i8 %x, %y
695 %cmpeq = icmp eq i8 %x, 255
696 %r = or i1 %cmp, %cmpeq
700 define i1 @uge_or_max_commute(i8 %x, i8 %y) {
701 ; CHECK-LABEL: @uge_or_max_commute(
702 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[X:%.*]], [[Y:%.*]]
703 ; CHECK-NEXT: ret i1 [[CMP]]
705 %cmp = icmp uge i8 %x, %y
706 %cmpeq = icmp eq i8 %x, 255
707 %r = or i1 %cmpeq, %cmp
711 define i1 @uge_swap_or_max(i8 %x, i8 %y) {
712 ; CHECK-LABEL: @uge_swap_or_max(
713 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
714 ; CHECK-NEXT: ret i1 [[CMP]]
716 %cmp = icmp ule i8 %y, %x
717 %cmpeq = icmp eq i8 %x, 255
718 %r = or i1 %cmp, %cmpeq
722 define i1 @uge_swap_or_max_commute(i8 %x, i8 %y) {
723 ; CHECK-LABEL: @uge_swap_or_max_commute(
724 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[X:%.*]]
725 ; CHECK-NEXT: ret i1 [[CMP]]
727 %cmp = icmp ule i8 %y, %x
728 %cmpeq = icmp eq i8 %x, 255
729 %r = or i1 %cmpeq, %cmp
733 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
735 ; (X == MIN) || (X <= Y) --> X <= Y
737 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
739 define i1 @sle_or_min(i8 %x, i8 %y) {
740 ; CHECK-LABEL: @sle_or_min(
741 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
742 ; CHECK-NEXT: ret i1 [[CMP]]
744 %cmp = icmp sle i8 %x, %y
745 %cmpeq = icmp eq i8 %x, 128
746 %r = or i1 %cmp, %cmpeq
750 define i1 @sle_or_min_commute(i8 %x, i8 %y) {
751 ; CHECK-LABEL: @sle_or_min_commute(
752 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[X:%.*]], [[Y:%.*]]
753 ; CHECK-NEXT: ret i1 [[CMP]]
755 %cmp = icmp sle i8 %x, %y
756 %cmpeq = icmp eq i8 %x, 128
757 %r = or i1 %cmpeq, %cmp
761 define i1 @sle_swap_or_min(i8 %x, i8 %y) {
762 ; CHECK-LABEL: @sle_swap_or_min(
763 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
764 ; CHECK-NEXT: ret i1 [[CMP]]
766 %cmp = icmp sge i8 %y, %x
767 %cmpeq = icmp eq i8 %x, 128
768 %r = or i1 %cmp, %cmpeq
772 define i1 @sle_swap_or_min_commute(i8 %x, i8 %y) {
773 ; CHECK-LABEL: @sle_swap_or_min_commute(
774 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[X:%.*]]
775 ; CHECK-NEXT: ret i1 [[CMP]]
777 %cmp = icmp sge i8 %y, %x
778 %cmpeq = icmp eq i8 %x, 128
779 %r = or i1 %cmpeq, %cmp
783 define i1 @ule_or_min(i8 %x, i8 %y) {
784 ; CHECK-LABEL: @ule_or_min(
785 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
786 ; CHECK-NEXT: ret i1 [[CMP]]
788 %cmp = icmp ule i8 %x, %y
789 %cmpeq = icmp eq i8 %x, 0
790 %r = or i1 %cmp, %cmpeq
794 define i1 @ule_or_min_commute(i8 %x, i8 %y) {
795 ; CHECK-LABEL: @ule_or_min_commute(
796 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[X:%.*]], [[Y:%.*]]
797 ; CHECK-NEXT: ret i1 [[CMP]]
799 %cmp = icmp ule i8 %x, %y
800 %cmpeq = icmp eq i8 %x, 0
801 %r = or i1 %cmpeq, %cmp
805 define i1 @ule_swap_or_min(i8 %x, i8 %y) {
806 ; CHECK-LABEL: @ule_swap_or_min(
807 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
808 ; CHECK-NEXT: ret i1 [[CMP]]
810 %cmp = icmp uge i8 %y, %x
811 %cmpeq = icmp eq i8 %x, 0
812 %r = or i1 %cmp, %cmpeq
816 define i1 @ule_swap_or_min_commute(i8 %x, i8 %y) {
817 ; CHECK-LABEL: @ule_swap_or_min_commute(
818 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[X:%.*]]
819 ; CHECK-NEXT: ret i1 [[CMP]]
821 %cmp = icmp uge i8 %y, %x
822 %cmpeq = icmp eq i8 %x, 0
823 %r = or i1 %cmpeq, %cmp
827 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
829 ; (X != MAX) && (X < Y) --> X < Y
831 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
833 define i1 @slt_and_not_max(i8 %x, i8 %y) {
834 ; CHECK-LABEL: @slt_and_not_max(
835 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
836 ; CHECK-NEXT: ret i1 [[CMP]]
838 %cmp = icmp slt i8 %x, %y
839 %cmpeq = icmp ne i8 %x, 127
840 %r = and i1 %cmp, %cmpeq
844 define i1 @slt_and_not_max_commute(i8 %x, i8 %y) {
845 ; CHECK-LABEL: @slt_and_not_max_commute(
846 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
847 ; CHECK-NEXT: ret i1 [[CMP]]
849 %cmp = icmp slt i8 %x, %y
850 %cmpeq = icmp ne i8 %x, 127
851 %r = and i1 %cmpeq, %cmp
855 define i1 @slt_swap_and_not_max(i8 %x, i8 %y) {
856 ; CHECK-LABEL: @slt_swap_and_not_max(
857 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
858 ; CHECK-NEXT: ret i1 [[CMP]]
860 %cmp = icmp sgt i8 %y, %x
861 %cmpeq = icmp ne i8 %x, 127
862 %r = and i1 %cmp, %cmpeq
866 define i1 @slt_swap_and_not_max_commute(i8 %x, i8 %y) {
867 ; CHECK-LABEL: @slt_swap_and_not_max_commute(
868 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
869 ; CHECK-NEXT: ret i1 [[CMP]]
871 %cmp = icmp sgt i8 %y, %x
872 %cmpeq = icmp ne i8 %x, 127
873 %r = and i1 %cmpeq, %cmp
877 define i1 @ult_and_not_max(i8 %x, i8 %y) {
878 ; CHECK-LABEL: @ult_and_not_max(
879 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
880 ; CHECK-NEXT: ret i1 [[CMP]]
882 %cmp = icmp ult i8 %x, %y
883 %cmpeq = icmp ne i8 %x, 255
884 %r = and i1 %cmp, %cmpeq
888 define i1 @ult_and_not_max_commute(i8 %x, i8 %y) {
889 ; CHECK-LABEL: @ult_and_not_max_commute(
890 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
891 ; CHECK-NEXT: ret i1 [[CMP]]
893 %cmp = icmp ult i8 %x, %y
894 %cmpeq = icmp ne i8 %x, 255
895 %r = and i1 %cmpeq, %cmp
899 define i1 @ult_swap_and_not_max(i8 %x, i8 %y) {
900 ; CHECK-LABEL: @ult_swap_and_not_max(
901 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
902 ; CHECK-NEXT: ret i1 [[CMP]]
904 %cmp = icmp ugt i8 %y, %x
905 %cmpeq = icmp ne i8 %x, 255
906 %r = and i1 %cmp, %cmpeq
910 define i1 @ult_swap_and_not_max_commute(i8 %x, i8 %y) {
911 ; CHECK-LABEL: @ult_swap_and_not_max_commute(
912 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
913 ; CHECK-NEXT: ret i1 [[CMP]]
915 %cmp = icmp ugt i8 %y, %x
916 %cmpeq = icmp ne i8 %x, 255
917 %r = and i1 %cmpeq, %cmp
921 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
923 ; (X != MIN) && (X > Y) --> X > Y
925 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
927 define i1 @sgt_and_not_min(i8 %x, i8 %y) {
928 ; CHECK-LABEL: @sgt_and_not_min(
929 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
930 ; CHECK-NEXT: ret i1 [[CMP]]
932 %cmp = icmp sgt i8 %x, %y
933 %cmpeq = icmp ne i8 %x, 128
934 %r = and i1 %cmp, %cmpeq
938 define i1 @sgt_and_not_min_commute(i8 %x, i8 %y) {
939 ; CHECK-LABEL: @sgt_and_not_min_commute(
940 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
941 ; CHECK-NEXT: ret i1 [[CMP]]
943 %cmp = icmp sgt i8 %x, %y
944 %cmpeq = icmp ne i8 %x, 128
945 %r = and i1 %cmpeq, %cmp
949 define i1 @sgt_swap_and_not_min(i8 %x, i8 %y) {
950 ; CHECK-LABEL: @sgt_swap_and_not_min(
951 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
952 ; CHECK-NEXT: ret i1 [[CMP]]
954 %cmp = icmp slt i8 %y, %x
955 %cmpeq = icmp ne i8 %x, 128
956 %r = and i1 %cmp, %cmpeq
960 define i1 @sgt_swap_and_not_min_commute(i8 %x, i8 %y) {
961 ; CHECK-LABEL: @sgt_swap_and_not_min_commute(
962 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
963 ; CHECK-NEXT: ret i1 [[CMP]]
965 %cmp = icmp slt i8 %y, %x
966 %cmpeq = icmp ne i8 %x, 128
967 %r = and i1 %cmpeq, %cmp
971 define i1 @ugt_and_not_min(i8 %x, i8 %y) {
972 ; CHECK-LABEL: @ugt_and_not_min(
973 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
974 ; CHECK-NEXT: ret i1 [[CMP]]
976 %cmp = icmp ugt i8 %x, %y
977 %cmpeq = icmp ne i8 %x, 0
978 %r = and i1 %cmp, %cmpeq
982 define i1 @ugt_and_not_min_commute(i8 %x, i8 %y) {
983 ; CHECK-LABEL: @ugt_and_not_min_commute(
984 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[X:%.*]], [[Y:%.*]]
985 ; CHECK-NEXT: ret i1 [[CMP]]
987 %cmp = icmp ugt i8 %x, %y
988 %cmpeq = icmp ne i8 %x, 0
989 %r = and i1 %cmpeq, %cmp
993 define i1 @ugt_swap_and_not_min(i8 %x, i8 %y) {
994 ; CHECK-LABEL: @ugt_swap_and_not_min(
995 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
996 ; CHECK-NEXT: ret i1 [[CMP]]
998 %cmp = icmp ult i8 %y, %x
999 %cmpeq = icmp ne i8 %x, 0
1000 %r = and i1 %cmp, %cmpeq
1004 define i1 @ugt_swap_and_not_min_commute(i8 %x, i8 %y) {
1005 ; CHECK-LABEL: @ugt_swap_and_not_min_commute(
1006 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[X:%.*]]
1007 ; CHECK-NEXT: ret i1 [[CMP]]
1009 %cmp = icmp ult i8 %y, %x
1010 %cmpeq = icmp ne i8 %x, 0
1011 %r = and i1 %cmpeq, %cmp
1015 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1017 ; (X != MAX) || (X < Y) --> X != MAX
1019 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1021 define i1 @slt_or_not_max(i8 %x, i8 %y) {
1022 ; CHECK-LABEL: @slt_or_not_max(
1023 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1024 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1025 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1026 ; CHECK-NEXT: ret i1 [[R]]
1028 %cmp = icmp slt i8 %x, %y
1029 %cmpeq = icmp ne i8 %x, 127
1030 %r = or i1 %cmp, %cmpeq
1034 define i1 @slt_or_not_max_commute(i8 %x, i8 %y) {
1035 ; CHECK-LABEL: @slt_or_not_max_commute(
1036 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[X:%.*]], [[Y:%.*]]
1037 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1038 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1039 ; CHECK-NEXT: ret i1 [[R]]
1041 %cmp = icmp slt i8 %x, %y
1042 %cmpeq = icmp ne i8 %x, 127
1043 %r = or i1 %cmpeq, %cmp
1047 define i1 @slt_swap_or_not_max(i8 %x, i8 %y) {
1048 ; CHECK-LABEL: @slt_swap_or_not_max(
1049 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1050 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1051 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1052 ; CHECK-NEXT: ret i1 [[R]]
1054 %cmp = icmp sgt i8 %y, %x
1055 %cmpeq = icmp ne i8 %x, 127
1056 %r = or i1 %cmp, %cmpeq
1060 define i1 @slt_swap_or_not_max_commute(i8 %x, i8 %y) {
1061 ; CHECK-LABEL: @slt_swap_or_not_max_commute(
1062 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[X:%.*]]
1063 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1064 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1065 ; CHECK-NEXT: ret i1 [[R]]
1067 %cmp = icmp sgt i8 %y, %x
1068 %cmpeq = icmp ne i8 %x, 127
1069 %r = or i1 %cmpeq, %cmp
1073 define i1 @ult_or_not_max(i8 %x, i8 %y) {
1074 ; CHECK-LABEL: @ult_or_not_max(
1075 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1076 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1077 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1078 ; CHECK-NEXT: ret i1 [[R]]
1080 %cmp = icmp ult i8 %x, %y
1081 %cmpeq = icmp ne i8 %x, 255
1082 %r = or i1 %cmp, %cmpeq
1086 define i1 @ult_or_not_max_commute(i8 %x, i8 %y) {
1087 ; CHECK-LABEL: @ult_or_not_max_commute(
1088 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[X:%.*]], [[Y:%.*]]
1089 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1090 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1091 ; CHECK-NEXT: ret i1 [[R]]
1093 %cmp = icmp ult i8 %x, %y
1094 %cmpeq = icmp ne i8 %x, 255
1095 %r = or i1 %cmpeq, %cmp
1099 define i1 @ult_swap_or_not_max(i8 %x, i8 %y) {
1100 ; CHECK-LABEL: @ult_swap_or_not_max(
1101 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1102 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1103 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1104 ; CHECK-NEXT: ret i1 [[R]]
1106 %cmp = icmp ugt i8 %y, %x
1107 %cmpeq = icmp ne i8 %x, 255
1108 %r = or i1 %cmp, %cmpeq
1112 define i1 @ult_swap_or_not_max_commute(i8 %x, i8 %y) {
1113 ; CHECK-LABEL: @ult_swap_or_not_max_commute(
1114 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[X:%.*]]
1115 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1116 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1117 ; CHECK-NEXT: ret i1 [[R]]
1119 %cmp = icmp ugt i8 %y, %x
1120 %cmpeq = icmp ne i8 %x, 255
1121 %r = or i1 %cmpeq, %cmp
1125 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1127 ; (X != MIN) || (X > Y) --> X != MIN
1129 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1131 define i1 @sgt_or_not_min(i8 %x, i8 %y) {
1132 ; CHECK-LABEL: @sgt_or_not_min(
1133 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1134 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1135 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1136 ; CHECK-NEXT: ret i1 [[R]]
1138 %cmp = icmp sgt i8 %x, %y
1139 %cmpeq = icmp ne i8 %x, 128
1140 %r = or i1 %cmp, %cmpeq
1144 define i1 @sgt_or_not_min_commute(i8 %x, i8 %y) {
1145 ; CHECK-LABEL: @sgt_or_not_min_commute(
1146 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[X:%.*]], [[Y:%.*]]
1147 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1148 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1149 ; CHECK-NEXT: ret i1 [[R]]
1151 %cmp = icmp sgt i8 %x, %y
1152 %cmpeq = icmp ne i8 %x, 128
1153 %r = or i1 %cmpeq, %cmp
1157 define i1 @sgt_swap_or_not_min(i8 %x, i8 %y) {
1158 ; CHECK-LABEL: @sgt_swap_or_not_min(
1159 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1160 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1161 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1162 ; CHECK-NEXT: ret i1 [[R]]
1164 %cmp = icmp slt i8 %y, %x
1165 %cmpeq = icmp ne i8 %x, 128
1166 %r = or i1 %cmp, %cmpeq
1170 define i1 @sgt_swap_or_not_min_commute(i8 %x, i8 %y) {
1171 ; CHECK-LABEL: @sgt_swap_or_not_min_commute(
1172 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[X:%.*]]
1173 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1174 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1175 ; CHECK-NEXT: ret i1 [[R]]
1177 %cmp = icmp slt i8 %y, %x
1178 %cmpeq = icmp ne i8 %x, 128
1179 %r = or i1 %cmpeq, %cmp
1183 define i1 @ugt_or_not_min(i8 %x, i8 %y) {
1184 ; CHECK-LABEL: @ugt_or_not_min(
1185 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
1186 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1188 %cmp = icmp ugt i8 %x, %y
1189 %cmpeq = icmp ne i8 %x, 0
1190 %r = or i1 %cmp, %cmpeq
1194 define i1 @ugt_or_not_min_commute(i8 %x, i8 %y) {
1195 ; CHECK-LABEL: @ugt_or_not_min_commute(
1196 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
1197 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1199 %cmp = icmp ugt i8 %x, %y
1200 %cmpeq = icmp ne i8 %x, 0
1201 %r = or i1 %cmpeq, %cmp
1205 define i1 @ugt_swap_or_not_min(i8 %x, i8 %y) {
1206 ; CHECK-LABEL: @ugt_swap_or_not_min(
1207 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X:%.*]], 0
1208 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1210 %cmp = icmp ult i8 %y, %x
1211 %cmpeq = icmp ne i8 %x, 0
1212 %r = or i1 %cmp, %cmpeq
1216 define i1 @ugt_swap_or_not_min_commute(i823 %x, i823 %y) {
1217 ; CHECK-LABEL: @ugt_swap_or_not_min_commute(
1218 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823 [[X:%.*]], 0
1219 ; CHECK-NEXT: ret i1 [[CMPEQ]]
1221 %cmp = icmp ult i823 %y, %x
1222 %cmpeq = icmp ne i823 %x, 0
1223 %r = or i1 %cmpeq, %cmp
1227 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1229 ; (X == MIN) && (!X < Y) --> false
1231 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1233 define i1 @slt_and_max_not_op(i8 %x, i8 %y) {
1234 ; CHECK-LABEL: @slt_and_max_not_op(
1235 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1236 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NOTX]], [[Y:%.*]]
1237 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1238 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1239 ; CHECK-NEXT: ret i1 [[R]]
1241 %notx = xor i8 %x, -1
1242 %cmp = icmp slt i8 %notx, %y
1243 %cmpeq = icmp eq i8 %x, 128
1244 %r = and i1 %cmp, %cmpeq
1248 define <2 x i1> @slt_and_max_commute_not_op(<2 x i8> %x, <2 x i8> %y) {
1249 ; CHECK-LABEL: @slt_and_max_commute_not_op(
1250 ; CHECK-NEXT: [[NOTX:%.*]] = xor <2 x i8> [[X:%.*]], <i8 -1, i8 -1>
1251 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt <2 x i8> [[NOTX]], [[Y:%.*]]
1252 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq <2 x i8> [[X]], <i8 -128, i8 -128>
1253 ; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[CMPEQ]], [[CMP]]
1254 ; CHECK-NEXT: ret <2 x i1> [[R]]
1256 %notx = xor <2 x i8> %x, <i8 -1, i8 -1>
1257 %cmp = icmp slt <2 x i8> %notx, %y
1258 %cmpeq = icmp eq <2 x i8> %x, <i8 128, i8 128>
1259 %r = and <2 x i1> %cmpeq, %cmp
1263 define i1 @slt_swap_and_max_not_op(i8 %x, i8 %y) {
1264 ; CHECK-LABEL: @slt_swap_and_max_not_op(
1265 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1266 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
1267 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1268 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1269 ; CHECK-NEXT: ret i1 [[R]]
1271 %notx = xor i8 %x, -1
1272 %cmp = icmp sgt i8 %y, %notx
1273 %cmpeq = icmp eq i8 %x, 128
1274 %r = and i1 %cmp, %cmpeq
1278 define i1 @slt_swap_and_max_commute_not_op(i8 %x, i8 %y) {
1279 ; CHECK-LABEL: @slt_swap_and_max_commute_not_op(
1280 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1281 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
1282 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1283 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1284 ; CHECK-NEXT: ret i1 [[R]]
1286 %notx = xor i8 %x, -1
1287 %cmp = icmp sgt i8 %y, %notx
1288 %cmpeq = icmp eq i8 %x, 128
1289 %r = and i1 %cmpeq, %cmp
1293 define i1 @ult_and_max_not_op(i8 %x, i8 %y) {
1294 ; CHECK-LABEL: @ult_and_max_not_op(
1295 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1296 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
1297 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1298 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1299 ; CHECK-NEXT: ret i1 [[R]]
1301 %notx = xor i8 %x, -1
1302 %cmp = icmp ult i8 %notx, %y
1303 %cmpeq = icmp eq i8 %x, 0
1304 %r = and i1 %cmp, %cmpeq
1308 define i1 @ult_and_max_commute_not_op(i8 %x, i8 %y) {
1309 ; CHECK-LABEL: @ult_and_max_commute_not_op(
1310 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1311 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
1312 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1313 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1314 ; CHECK-NEXT: ret i1 [[R]]
1316 %notx = xor i8 %x, -1
1317 %cmp = icmp ult i8 %notx, %y
1318 %cmpeq = icmp eq i8 %x, 0
1319 %r = and i1 %cmpeq, %cmp
1323 define i1 @ult_swap_and_max_not_op(i8 %x, i8 %y) {
1324 ; CHECK-LABEL: @ult_swap_and_max_not_op(
1325 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1326 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
1327 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1328 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1329 ; CHECK-NEXT: ret i1 [[R]]
1331 %notx = xor i8 %x, -1
1332 %cmp = icmp ugt i8 %y, %notx
1333 %cmpeq = icmp eq i8 %x, 0
1334 %r = and i1 %cmp, %cmpeq
1338 define i1 @ult_swap_and_max_commute_not_op(i8 %x, i8 %y) {
1339 ; CHECK-LABEL: @ult_swap_and_max_commute_not_op(
1340 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1341 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
1342 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1343 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1344 ; CHECK-NEXT: ret i1 [[R]]
1346 %notx = xor i8 %x, -1
1347 %cmp = icmp ugt i8 %y, %notx
1348 %cmpeq = icmp eq i8 %x, 0
1349 %r = and i1 %cmpeq, %cmp
1353 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1355 ; (X == MAX) && (!X > Y) --> false
1357 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1359 define i1 @sgt_and_min_not_op(i9 %x, i9 %y) {
1360 ; CHECK-LABEL: @sgt_and_min_not_op(
1361 ; CHECK-NEXT: [[NOTX:%.*]] = xor i9 [[X:%.*]], -1
1362 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i9 [[NOTX]], [[Y:%.*]]
1363 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i9 [[X]], 255
1364 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1365 ; CHECK-NEXT: ret i1 [[R]]
1367 %notx = xor i9 %x, -1
1368 %cmp = icmp sgt i9 %notx, %y
1369 %cmpeq = icmp eq i9 %x, 255
1370 %r = and i1 %cmp, %cmpeq
1374 define i1 @sgt_and_min_commute_not_op(i8 %x, i8 %y) {
1375 ; CHECK-LABEL: @sgt_and_min_commute_not_op(
1376 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1377 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NOTX]], [[Y:%.*]]
1378 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
1379 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1380 ; CHECK-NEXT: ret i1 [[R]]
1382 %notx = xor i8 %x, -1
1383 %cmp = icmp sgt i8 %notx, %y
1384 %cmpeq = icmp eq i8 %x, 127
1385 %r = and i1 %cmpeq, %cmp
1389 define i1 @sgt_swap_and_min_not_op(i8 %x, i8 %y) {
1390 ; CHECK-LABEL: @sgt_swap_and_min_not_op(
1391 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1392 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
1393 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
1394 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1395 ; CHECK-NEXT: ret i1 [[R]]
1397 %notx = xor i8 %x, -1
1398 %cmp = icmp slt i8 %y, %notx
1399 %cmpeq = icmp eq i8 %x, 127
1400 %r = and i1 %cmp, %cmpeq
1404 define i1 @sgt_swap_and_min_commute_not_op(i8 %x, i8 %y) {
1405 ; CHECK-LABEL: @sgt_swap_and_min_commute_not_op(
1406 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1407 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
1408 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 127
1409 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1410 ; CHECK-NEXT: ret i1 [[R]]
1412 %notx = xor i8 %x, -1
1413 %cmp = icmp slt i8 %y, %notx
1414 %cmpeq = icmp eq i8 %x, 127
1415 %r = and i1 %cmpeq, %cmp
1419 define i1 @ugt_and_min_not_op(i8 %x, i8 %y) {
1420 ; CHECK-LABEL: @ugt_and_min_not_op(
1421 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1422 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
1423 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1424 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1425 ; CHECK-NEXT: ret i1 [[R]]
1427 %notx = xor i8 %x, -1
1428 %cmp = icmp ugt i8 %notx, %y
1429 %cmpeq = icmp eq i8 %x, 255
1430 %r = and i1 %cmp, %cmpeq
1434 define i1 @ugt_and_min_commute_not_op(i8 %x, i8 %y) {
1435 ; CHECK-LABEL: @ugt_and_min_commute_not_op(
1436 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1437 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
1438 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1439 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1440 ; CHECK-NEXT: ret i1 [[R]]
1442 %notx = xor i8 %x, -1
1443 %cmp = icmp ugt i8 %notx, %y
1444 %cmpeq = icmp eq i8 %x, 255
1445 %r = and i1 %cmpeq, %cmp
1449 define i1 @ugt_swap_and_min_not_op(i8 %x, i8 %y) {
1450 ; CHECK-LABEL: @ugt_swap_and_min_not_op(
1451 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1452 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[NOTX]]
1453 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1454 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1455 ; CHECK-NEXT: ret i1 [[R]]
1457 %notx = xor i8 %x, -1
1458 %cmp = icmp ult i8 %y, %notx
1459 %cmpeq = icmp eq i8 %x, 255
1460 %r = and i1 %cmp, %cmpeq
1464 define i1 @ugt_swap_and_min_commute_not_op(i8 %x, i8 %y) {
1465 ; CHECK-LABEL: @ugt_swap_and_min_commute_not_op(
1466 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1467 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[NOTX]]
1468 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -1
1469 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1470 ; CHECK-NEXT: ret i1 [[R]]
1472 %notx = xor i8 %x, -1
1473 %cmp = icmp ult i8 %y, %notx
1474 %cmpeq = icmp eq i8 %x, 255
1475 %r = and i1 %cmpeq, %cmp
1479 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1481 ; (X != MIN) || (!X >= Y) --> true
1483 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1485 define i1 @sge_or_not_max_not_op(i8 %x, i8 %y) {
1486 ; CHECK-LABEL: @sge_or_not_max_not_op(
1487 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1488 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
1489 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1490 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1491 ; CHECK-NEXT: ret i1 [[R]]
1493 %notx = xor i8 %x, -1
1494 %cmp = icmp sge i8 %notx, %y
1495 %cmpeq = icmp ne i8 %x, 128
1496 %r = or i1 %cmp, %cmpeq
1500 define i1 @sge_or_not_max_commute_not_op(i8 %x, i8 %y) {
1501 ; CHECK-LABEL: @sge_or_not_max_commute_not_op(
1502 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1503 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
1504 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1505 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1506 ; CHECK-NEXT: ret i1 [[R]]
1508 %notx = xor i8 %x, -1
1509 %cmp = icmp sge i8 %notx, %y
1510 %cmpeq = icmp ne i8 %x, 128
1511 %r = or i1 %cmpeq, %cmp
1515 define i1 @sge_swap_or_not_max_not_op(i8 %x, i8 %y) {
1516 ; CHECK-LABEL: @sge_swap_or_not_max_not_op(
1517 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1518 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
1519 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1520 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1521 ; CHECK-NEXT: ret i1 [[R]]
1523 %notx = xor i8 %x, -1
1524 %cmp = icmp sle i8 %y, %notx
1525 %cmpeq = icmp ne i8 %x, 128
1526 %r = or i1 %cmp, %cmpeq
1530 define i1 @sge_swap_or_not_max_commute_not_op(i8 %x, i8 %y) {
1531 ; CHECK-LABEL: @sge_swap_or_not_max_commute_not_op(
1532 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1533 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
1534 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
1535 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1536 ; CHECK-NEXT: ret i1 [[R]]
1538 %notx = xor i8 %x, -1
1539 %cmp = icmp sle i8 %y, %notx
1540 %cmpeq = icmp ne i8 %x, 128
1541 %r = or i1 %cmpeq, %cmp
1545 define i1 @uge_or_not_max_not_op(i8 %x, i8 %y) {
1546 ; CHECK-LABEL: @uge_or_not_max_not_op(
1547 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1548 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
1549 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1550 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1551 ; CHECK-NEXT: ret i1 [[R]]
1553 %notx = xor i8 %x, -1
1554 %cmp = icmp uge i8 %notx, %y
1555 %cmpeq = icmp ne i8 %x, 0
1556 %r = or i1 %cmp, %cmpeq
1560 define i1 @uge_or_not_max_commute_not_op(i8 %x, i8 %y) {
1561 ; CHECK-LABEL: @uge_or_not_max_commute_not_op(
1562 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1563 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
1564 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1565 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1566 ; CHECK-NEXT: ret i1 [[R]]
1568 %notx = xor i8 %x, -1
1569 %cmp = icmp uge i8 %notx, %y
1570 %cmpeq = icmp ne i8 %x, 0
1571 %r = or i1 %cmpeq, %cmp
1575 define i1 @uge_swap_or_not_max_not_op(i8 %x, i8 %y) {
1576 ; CHECK-LABEL: @uge_swap_or_not_max_not_op(
1577 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1578 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
1579 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1580 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1581 ; CHECK-NEXT: ret i1 [[R]]
1583 %notx = xor i8 %x, -1
1584 %cmp = icmp ule i8 %y, %notx
1585 %cmpeq = icmp ne i8 %x, 0
1586 %r = or i1 %cmp, %cmpeq
1590 define i1 @uge_swap_or_not_max_commute_not_op(i8 %x, i8 %y) {
1591 ; CHECK-LABEL: @uge_swap_or_not_max_commute_not_op(
1592 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1593 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
1594 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
1595 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1596 ; CHECK-NEXT: ret i1 [[R]]
1598 %notx = xor i8 %x, -1
1599 %cmp = icmp ule i8 %y, %notx
1600 %cmpeq = icmp ne i8 %x, 0
1601 %r = or i1 %cmpeq, %cmp
1605 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1607 ; (X != MAX) || (!X <= Y) --> true
1609 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1611 define i1 @sle_or_not_min_not_op(i8 %x, i8 %y) {
1612 ; CHECK-LABEL: @sle_or_not_min_not_op(
1613 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1614 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
1615 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1616 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1617 ; CHECK-NEXT: ret i1 [[R]]
1619 %notx = xor i8 %x, -1
1620 %cmp = icmp sle i8 %notx, %y
1621 %cmpeq = icmp ne i8 %x, 127
1622 %r = or i1 %cmp, %cmpeq
1626 define i1 @sle_or_not_min_commute_not_op(i8 %x, i8 %y) {
1627 ; CHECK-LABEL: @sle_or_not_min_commute_not_op(
1628 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1629 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
1630 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1631 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1632 ; CHECK-NEXT: ret i1 [[R]]
1634 %notx = xor i8 %x, -1
1635 %cmp = icmp sle i8 %notx, %y
1636 %cmpeq = icmp ne i8 %x, 127
1637 %r = or i1 %cmpeq, %cmp
1641 define i1 @sle_swap_or_not_min_not_op(i8 %x, i8 %y) {
1642 ; CHECK-LABEL: @sle_swap_or_not_min_not_op(
1643 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1644 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
1645 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1646 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1647 ; CHECK-NEXT: ret i1 [[R]]
1649 %notx = xor i8 %x, -1
1650 %cmp = icmp sge i8 %y, %notx
1651 %cmpeq = icmp ne i8 %x, 127
1652 %r = or i1 %cmp, %cmpeq
1656 define i1 @sle_swap_or_not_min_commute_not_op(i8 %x, i8 %y) {
1657 ; CHECK-LABEL: @sle_swap_or_not_min_commute_not_op(
1658 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1659 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
1660 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
1661 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1662 ; CHECK-NEXT: ret i1 [[R]]
1664 %notx = xor i8 %x, -1
1665 %cmp = icmp sge i8 %y, %notx
1666 %cmpeq = icmp ne i8 %x, 127
1667 %r = or i1 %cmpeq, %cmp
1671 define i1 @ule_or_not_min_not_op(i427 %x, i427 %y) {
1672 ; CHECK-LABEL: @ule_or_not_min_not_op(
1673 ; CHECK-NEXT: [[NOTX:%.*]] = xor i427 [[X:%.*]], -1
1674 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i427 [[NOTX]], [[Y:%.*]]
1675 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i427 [[X]], -1
1676 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1677 ; CHECK-NEXT: ret i1 [[R]]
1679 %notx = xor i427 %x, -1
1680 %cmp = icmp ule i427 %notx, %y
1681 %cmpeq = icmp ne i427 %x, -1
1682 %r = or i1 %cmp, %cmpeq
1686 define i1 @ule_or_not_min_commute_not_op(i8 %x, i8 %y) {
1687 ; CHECK-LABEL: @ule_or_not_min_commute_not_op(
1688 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1689 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NOTX]], [[Y:%.*]]
1690 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1691 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1692 ; CHECK-NEXT: ret i1 [[R]]
1694 %notx = xor i8 %x, -1
1695 %cmp = icmp ule i8 %notx, %y
1696 %cmpeq = icmp ne i8 %x, 255
1697 %r = or i1 %cmpeq, %cmp
1701 define i1 @ule_swap_or_not_min_not_op(i8 %x, i8 %y) {
1702 ; CHECK-LABEL: @ule_swap_or_not_min_not_op(
1703 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1704 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
1705 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1706 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
1707 ; CHECK-NEXT: ret i1 [[R]]
1709 %notx = xor i8 %x, -1
1710 %cmp = icmp uge i8 %y, %notx
1711 %cmpeq = icmp ne i8 %x, 255
1712 %r = or i1 %cmp, %cmpeq
1716 define i1 @ule_swap_or_not_min_commute_not_op(i8 %x, i8 %y) {
1717 ; CHECK-LABEL: @ule_swap_or_not_min_commute_not_op(
1718 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1719 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
1720 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
1721 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
1722 ; CHECK-NEXT: ret i1 [[R]]
1724 %notx = xor i8 %x, -1
1725 %cmp = icmp uge i8 %y, %notx
1726 %cmpeq = icmp ne i8 %x, 255
1727 %r = or i1 %cmpeq, %cmp
1731 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1733 ; (X == MIN) && (!X >= Y) --> X == MIN
1735 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1737 define i1 @sge_and_max_not_op(i8 %x, i8 %y) {
1738 ; CHECK-LABEL: @sge_and_max_not_op(
1739 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1740 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
1741 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1742 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1743 ; CHECK-NEXT: ret i1 [[R]]
1745 %notx = xor i8 %x, -1
1746 %cmp = icmp sge i8 %notx, %y
1747 %cmpeq = icmp eq i8 %x, 128
1748 %r = and i1 %cmp, %cmpeq
1752 define i1 @sge_and_max_commute_not_op(i8 %x, i8 %y) {
1753 ; CHECK-LABEL: @sge_and_max_commute_not_op(
1754 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1755 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
1756 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1757 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1758 ; CHECK-NEXT: ret i1 [[R]]
1760 %notx = xor i8 %x, -1
1761 %cmp = icmp sge i8 %notx, %y
1762 %cmpeq = icmp eq i8 %x, 128
1763 %r = and i1 %cmpeq, %cmp
1767 define i1 @sge_swap_and_max_not_op(i8 %x, i8 %y) {
1768 ; CHECK-LABEL: @sge_swap_and_max_not_op(
1769 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1770 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
1771 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1772 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1773 ; CHECK-NEXT: ret i1 [[R]]
1775 %notx = xor i8 %x, -1
1776 %cmp = icmp sle i8 %y, %notx
1777 %cmpeq = icmp eq i8 %x, 128
1778 %r = and i1 %cmp, %cmpeq
1782 define i1 @sge_swap_and_max_commute_not_op(i8 %x, i8 %y) {
1783 ; CHECK-LABEL: @sge_swap_and_max_commute_not_op(
1784 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1785 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
1786 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1787 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1788 ; CHECK-NEXT: ret i1 [[R]]
1790 %notx = xor i8 %x, -1
1791 %cmp = icmp sle i8 %y, %notx
1792 %cmpeq = icmp eq i8 %x, 128
1793 %r = and i1 %cmpeq, %cmp
1797 define i1 @uge_and_max_not_op(i8 %x, i8 %y) {
1798 ; CHECK-LABEL: @uge_and_max_not_op(
1799 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1800 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
1801 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1802 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1803 ; CHECK-NEXT: ret i1 [[R]]
1805 %notx = xor i8 %x, -1
1806 %cmp = icmp uge i8 %notx, %y
1807 %cmpeq = icmp eq i8 %x, 0
1808 %r = and i1 %cmp, %cmpeq
1812 define i1 @uge_and_max_commute_not_op(i8 %x, i8 %y) {
1813 ; CHECK-LABEL: @uge_and_max_commute_not_op(
1814 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1815 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
1816 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1817 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1818 ; CHECK-NEXT: ret i1 [[R]]
1820 %notx = xor i8 %x, -1
1821 %cmp = icmp uge i8 %notx, %y
1822 %cmpeq = icmp eq i8 %x, 0
1823 %r = and i1 %cmpeq, %cmp
1827 define i1 @uge_swap_and_max_not_op(i8 %x, i8 %y) {
1828 ; CHECK-LABEL: @uge_swap_and_max_not_op(
1829 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1830 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
1831 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1832 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1833 ; CHECK-NEXT: ret i1 [[R]]
1835 %notx = xor i8 %x, -1
1836 %cmp = icmp ule i8 %y, %notx
1837 %cmpeq = icmp eq i8 %x, 0
1838 %r = and i1 %cmp, %cmpeq
1842 define i1 @uge_swap_and_max_commute_not_op(i8 %x, i8 %y) {
1843 ; CHECK-LABEL: @uge_swap_and_max_commute_not_op(
1844 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1845 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
1846 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1847 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1848 ; CHECK-NEXT: ret i1 [[R]]
1850 %notx = xor i8 %x, -1
1851 %cmp = icmp ule i8 %y, %notx
1852 %cmpeq = icmp eq i8 %x, 0
1853 %r = and i1 %cmpeq, %cmp
1857 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1859 ; (X == MIN) && (!X <= Y) --> X == MIN
1861 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1863 define i1 @sle_and_min_not_op(i8 %x, i8 %y) {
1864 ; CHECK-LABEL: @sle_and_min_not_op(
1865 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1866 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
1867 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1868 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1869 ; CHECK-NEXT: ret i1 [[R]]
1871 %notx = xor i8 %x, -1
1872 %cmp = icmp sle i8 %notx, %y
1873 %cmpeq = icmp eq i8 %x, 128
1874 %r = and i1 %cmp, %cmpeq
1878 define i1 @sle_and_min_commute_not_op(i8 %x, i8 %y) {
1879 ; CHECK-LABEL: @sle_and_min_commute_not_op(
1880 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1881 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
1882 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1883 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1884 ; CHECK-NEXT: ret i1 [[R]]
1886 %notx = xor i8 %x, -1
1887 %cmp = icmp sle i8 %notx, %y
1888 %cmpeq = icmp eq i8 %x, 128
1889 %r = and i1 %cmpeq, %cmp
1893 define i1 @sle_swap_and_min_not_op(i8 %x, i8 %y) {
1894 ; CHECK-LABEL: @sle_swap_and_min_not_op(
1895 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1896 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
1897 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1898 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1899 ; CHECK-NEXT: ret i1 [[R]]
1901 %notx = xor i8 %x, -1
1902 %cmp = icmp sge i8 %y, %notx
1903 %cmpeq = icmp eq i8 %x, 128
1904 %r = and i1 %cmp, %cmpeq
1908 define i1 @sle_swap_and_min_commute_not_op(i8 %x, i8 %y) {
1909 ; CHECK-LABEL: @sle_swap_and_min_commute_not_op(
1910 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1911 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
1912 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], -128
1913 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1914 ; CHECK-NEXT: ret i1 [[R]]
1916 %notx = xor i8 %x, -1
1917 %cmp = icmp sge i8 %y, %notx
1918 %cmpeq = icmp eq i8 %x, 128
1919 %r = and i1 %cmpeq, %cmp
1923 define i1 @ule_and_min_not_op(i8 %x, i8 %y) {
1924 ; CHECK-LABEL: @ule_and_min_not_op(
1925 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1926 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NOTX]], [[Y:%.*]]
1927 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1928 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1929 ; CHECK-NEXT: ret i1 [[R]]
1931 %notx = xor i8 %x, -1
1932 %cmp = icmp ule i8 %notx, %y
1933 %cmpeq = icmp eq i8 %x, 0
1934 %r = and i1 %cmp, %cmpeq
1938 define i1 @ule_and_min_commute_not_op(i8 %x, i8 %y) {
1939 ; CHECK-LABEL: @ule_and_min_commute_not_op(
1940 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1941 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NOTX]], [[Y:%.*]]
1942 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1943 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1944 ; CHECK-NEXT: ret i1 [[R]]
1946 %notx = xor i8 %x, -1
1947 %cmp = icmp ule i8 %notx, %y
1948 %cmpeq = icmp eq i8 %x, 0
1949 %r = and i1 %cmpeq, %cmp
1953 define i1 @ule_swap_and_min_not_op(i8 %x, i8 %y) {
1954 ; CHECK-LABEL: @ule_swap_and_min_not_op(
1955 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1956 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
1957 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1958 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
1959 ; CHECK-NEXT: ret i1 [[R]]
1961 %notx = xor i8 %x, -1
1962 %cmp = icmp uge i8 %y, %notx
1963 %cmpeq = icmp eq i8 %x, 0
1964 %r = and i1 %cmp, %cmpeq
1968 define i1 @ule_swap_and_min_commute_not_op(i8 %x, i8 %y) {
1969 ; CHECK-LABEL: @ule_swap_and_min_commute_not_op(
1970 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1971 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
1972 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8 [[X]], 0
1973 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMPEQ]], [[CMP]]
1974 ; CHECK-NEXT: ret i1 [[R]]
1976 %notx = xor i8 %x, -1
1977 %cmp = icmp uge i8 %y, %notx
1978 %cmpeq = icmp eq i8 %x, 0
1979 %r = and i1 %cmpeq, %cmp
1983 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1985 ; (X == MIN) || (!X >= Y) --> !X >= Y
1987 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1989 define i1 @sge_or_max_not_op(i8 %x, i8 %y) {
1990 ; CHECK-LABEL: @sge_or_max_not_op(
1991 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
1992 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
1993 ; CHECK-NEXT: ret i1 [[CMP]]
1995 %notx = xor i8 %x, -1
1996 %cmp = icmp sge i8 %notx, %y
1997 %cmpeq = icmp eq i8 %x, 128
1998 %r = or i1 %cmp, %cmpeq
2002 define i1 @sge_or_max_commute_not_op(i8 %x, i8 %y) {
2003 ; CHECK-LABEL: @sge_or_max_commute_not_op(
2004 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2005 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[NOTX]], [[Y:%.*]]
2006 ; CHECK-NEXT: ret i1 [[CMP]]
2008 %notx = xor i8 %x, -1
2009 %cmp = icmp sge i8 %notx, %y
2010 %cmpeq = icmp eq i8 %x, 128
2011 %r = or i1 %cmpeq, %cmp
2015 define i1 @sge_swap_or_max_not_op(i8 %x, i8 %y) {
2016 ; CHECK-LABEL: @sge_swap_or_max_not_op(
2017 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2018 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
2019 ; CHECK-NEXT: ret i1 [[CMP]]
2021 %notx = xor i8 %x, -1
2022 %cmp = icmp sle i8 %y, %notx
2023 %cmpeq = icmp eq i8 %x, 128
2024 %r = or i1 %cmp, %cmpeq
2028 define i1 @sge_swap_or_max_commute_not_op(i8 %x, i8 %y) {
2029 ; CHECK-LABEL: @sge_swap_or_max_commute_not_op(
2030 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2031 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[Y:%.*]], [[NOTX]]
2032 ; CHECK-NEXT: ret i1 [[CMP]]
2034 %notx = xor i8 %x, -1
2035 %cmp = icmp sle i8 %y, %notx
2036 %cmpeq = icmp eq i8 %x, 128
2037 %r = or i1 %cmpeq, %cmp
2041 define i1 @uge_or_max_not_op(i8 %x, i8 %y) {
2042 ; CHECK-LABEL: @uge_or_max_not_op(
2043 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2044 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
2045 ; CHECK-NEXT: ret i1 [[CMP]]
2047 %notx = xor i8 %x, -1
2048 %cmp = icmp uge i8 %notx, %y
2049 %cmpeq = icmp eq i8 %x, 0
2050 %r = or i1 %cmp, %cmpeq
2054 define i1 @uge_or_max_commute_not_op(i8 %x, i8 %y) {
2055 ; CHECK-LABEL: @uge_or_max_commute_not_op(
2056 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2057 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[NOTX]], [[Y:%.*]]
2058 ; CHECK-NEXT: ret i1 [[CMP]]
2060 %notx = xor i8 %x, -1
2061 %cmp = icmp uge i8 %notx, %y
2062 %cmpeq = icmp eq i8 %x, 0
2063 %r = or i1 %cmpeq, %cmp
2067 define i1 @uge_swap_or_max_not_op(i8 %x, i8 %y) {
2068 ; CHECK-LABEL: @uge_swap_or_max_not_op(
2069 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2070 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
2071 ; CHECK-NEXT: ret i1 [[CMP]]
2073 %notx = xor i8 %x, -1
2074 %cmp = icmp ule i8 %y, %notx
2075 %cmpeq = icmp eq i8 %x, 0
2076 %r = or i1 %cmp, %cmpeq
2080 define i1 @uge_swap_or_max_commute_not_op(i8 %x, i8 %y) {
2081 ; CHECK-LABEL: @uge_swap_or_max_commute_not_op(
2082 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2083 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[Y:%.*]], [[NOTX]]
2084 ; CHECK-NEXT: ret i1 [[CMP]]
2086 %notx = xor i8 %x, -1
2087 %cmp = icmp ule i8 %y, %notx
2088 %cmpeq = icmp eq i8 %x, 0
2089 %r = or i1 %cmpeq, %cmp
2093 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2095 ; (X == MAX) || (!X <= Y) --> !X <= Y
2097 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2099 define i1 @sle_or_min_not_op(i8 %x, i8 %y) {
2100 ; CHECK-LABEL: @sle_or_min_not_op(
2101 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2102 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
2103 ; CHECK-NEXT: ret i1 [[CMP]]
2105 %notx = xor i8 %x, -1
2106 %cmp = icmp sle i8 %notx, %y
2107 %cmpeq = icmp eq i8 %x, 127
2108 %r = or i1 %cmp, %cmpeq
2112 define i1 @sle_or_min_commute_not_op(i8 %x, i8 %y) {
2113 ; CHECK-LABEL: @sle_or_min_commute_not_op(
2114 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2115 ; CHECK-NEXT: [[CMP:%.*]] = icmp sle i8 [[NOTX]], [[Y:%.*]]
2116 ; CHECK-NEXT: ret i1 [[CMP]]
2118 %notx = xor i8 %x, -1
2119 %cmp = icmp sle i8 %notx, %y
2120 %cmpeq = icmp eq i8 %x, 127
2121 %r = or i1 %cmpeq, %cmp
2125 define i1 @sle_swap_or_min_not_op(i8 %x, i8 %y) {
2126 ; CHECK-LABEL: @sle_swap_or_min_not_op(
2127 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2128 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
2129 ; CHECK-NEXT: ret i1 [[CMP]]
2131 %notx = xor i8 %x, -1
2132 %cmp = icmp sge i8 %y, %notx
2133 %cmpeq = icmp eq i8 %x, 127
2134 %r = or i1 %cmp, %cmpeq
2138 define i1 @sle_swap_or_min_commute_not_op(i8 %x, i8 %y) {
2139 ; CHECK-LABEL: @sle_swap_or_min_commute_not_op(
2140 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2141 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i8 [[Y:%.*]], [[NOTX]]
2142 ; CHECK-NEXT: ret i1 [[CMP]]
2144 %notx = xor i8 %x, -1
2145 %cmp = icmp sge i8 %y, %notx
2146 %cmpeq = icmp eq i8 %x, 127
2147 %r = or i1 %cmpeq, %cmp
2151 define i1 @ule_or_min_not_op(i8 %x, i8 %y) {
2152 ; CHECK-LABEL: @ule_or_min_not_op(
2153 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2154 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NOTX]], [[Y:%.*]]
2155 ; CHECK-NEXT: ret i1 [[CMP]]
2157 %notx = xor i8 %x, -1
2158 %cmp = icmp ule i8 %notx, %y
2159 %cmpeq = icmp eq i8 %x, 255
2160 %r = or i1 %cmp, %cmpeq
2164 define i1 @ule_or_min_commute_not_op(i8 %x, i8 %y) {
2165 ; CHECK-LABEL: @ule_or_min_commute_not_op(
2166 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2167 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8 [[NOTX]], [[Y:%.*]]
2168 ; CHECK-NEXT: ret i1 [[CMP]]
2170 %notx = xor i8 %x, -1
2171 %cmp = icmp ule i8 %notx, %y
2172 %cmpeq = icmp eq i8 %x, 255
2173 %r = or i1 %cmpeq, %cmp
2177 define i1 @ule_swap_or_min_not_op(i8 %x, i8 %y) {
2178 ; CHECK-LABEL: @ule_swap_or_min_not_op(
2179 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2180 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
2181 ; CHECK-NEXT: ret i1 [[CMP]]
2183 %notx = xor i8 %x, -1
2184 %cmp = icmp uge i8 %y, %notx
2185 %cmpeq = icmp eq i8 %x, 255
2186 %r = or i1 %cmp, %cmpeq
2190 define i1 @ule_swap_or_min_commute_not_op(i8 %x, i8 %y) {
2191 ; CHECK-LABEL: @ule_swap_or_min_commute_not_op(
2192 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2193 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8 [[Y:%.*]], [[NOTX]]
2194 ; CHECK-NEXT: ret i1 [[CMP]]
2196 %notx = xor i8 %x, -1
2197 %cmp = icmp uge i8 %y, %notx
2198 %cmpeq = icmp eq i8 %x, 255
2199 %r = or i1 %cmpeq, %cmp
2203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2205 ; (X != MIN) && (!X < Y) --> !X < Y
2207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2209 define i1 @slt_and_not_max_not_op(i8 %x, i8 %y) {
2210 ; CHECK-LABEL: @slt_and_not_max_not_op(
2211 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2212 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NOTX]], [[Y:%.*]]
2213 ; CHECK-NEXT: ret i1 [[CMP]]
2215 %notx = xor i8 %x, -1
2216 %cmp = icmp slt i8 %notx, %y
2217 %cmpeq = icmp ne i8 %x, 128
2218 %r = and i1 %cmp, %cmpeq
2222 define i1 @slt_and_not_max_commute_not_op(i8 %x, i8 %y) {
2223 ; CHECK-LABEL: @slt_and_not_max_commute_not_op(
2224 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2225 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NOTX]], [[Y:%.*]]
2226 ; CHECK-NEXT: ret i1 [[CMP]]
2228 %notx = xor i8 %x, -1
2229 %cmp = icmp slt i8 %notx, %y
2230 %cmpeq = icmp ne i8 %x, 128
2231 %r = and i1 %cmpeq, %cmp
2235 define i1 @slt_swap_and_not_max_not_op(i8 %x, i8 %y) {
2236 ; CHECK-LABEL: @slt_swap_and_not_max_not_op(
2237 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2238 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
2239 ; CHECK-NEXT: ret i1 [[CMP]]
2241 %notx = xor i8 %x, -1
2242 %cmp = icmp sgt i8 %y, %notx
2243 %cmpeq = icmp ne i8 %x, 128
2244 %r = and i1 %cmp, %cmpeq
2248 define i1 @slt_swap_and_not_max_commute_not_op(i8 %x, i8 %y) {
2249 ; CHECK-LABEL: @slt_swap_and_not_max_commute_not_op(
2250 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2251 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
2252 ; CHECK-NEXT: ret i1 [[CMP]]
2254 %notx = xor i8 %x, -1
2255 %cmp = icmp sgt i8 %y, %notx
2256 %cmpeq = icmp ne i8 %x, 128
2257 %r = and i1 %cmpeq, %cmp
2261 define i1 @ult_and_not_max_not_op(i8 %x, i8 %y) {
2262 ; CHECK-LABEL: @ult_and_not_max_not_op(
2263 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2264 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
2265 ; CHECK-NEXT: ret i1 [[CMP]]
2267 %notx = xor i8 %x, -1
2268 %cmp = icmp ult i8 %notx, %y
2269 %cmpeq = icmp ne i8 %x, 0
2270 %r = and i1 %cmp, %cmpeq
2274 define i1 @ult_and_not_max_commute_not_op(i8 %x, i8 %y) {
2275 ; CHECK-LABEL: @ult_and_not_max_commute_not_op(
2276 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2277 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
2278 ; CHECK-NEXT: ret i1 [[CMP]]
2280 %notx = xor i8 %x, -1
2281 %cmp = icmp ult i8 %notx, %y
2282 %cmpeq = icmp ne i8 %x, 0
2283 %r = and i1 %cmpeq, %cmp
2287 define i1 @ult_swap_and_not_max_not_op(i8 %x, i8 %y) {
2288 ; CHECK-LABEL: @ult_swap_and_not_max_not_op(
2289 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2290 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
2291 ; CHECK-NEXT: ret i1 [[CMP]]
2293 %notx = xor i8 %x, -1
2294 %cmp = icmp ugt i8 %y, %notx
2295 %cmpeq = icmp ne i8 %x, 0
2296 %r = and i1 %cmp, %cmpeq
2300 define i1 @ult_swap_and_not_max_commute_not_op(i8 %x, i8 %y) {
2301 ; CHECK-LABEL: @ult_swap_and_not_max_commute_not_op(
2302 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2303 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
2304 ; CHECK-NEXT: ret i1 [[CMP]]
2306 %notx = xor i8 %x, -1
2307 %cmp = icmp ugt i8 %y, %notx
2308 %cmpeq = icmp ne i8 %x, 0
2309 %r = and i1 %cmpeq, %cmp
2313 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2315 ; (X != MAX) && (!X > Y) --> !X > Y
2317 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2319 define i1 @sgt_and_not_min_not_op(i8 %x, i8 %y) {
2320 ; CHECK-LABEL: @sgt_and_not_min_not_op(
2321 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2322 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NOTX]], [[Y:%.*]]
2323 ; CHECK-NEXT: ret i1 [[CMP]]
2325 %notx = xor i8 %x, -1
2326 %cmp = icmp sgt i8 %notx, %y
2327 %cmpeq = icmp ne i8 %x, 127
2328 %r = and i1 %cmp, %cmpeq
2332 define i1 @sgt_and_not_min_commute_not_op(i8 %x, i8 %y) {
2333 ; CHECK-LABEL: @sgt_and_not_min_commute_not_op(
2334 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2335 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NOTX]], [[Y:%.*]]
2336 ; CHECK-NEXT: ret i1 [[CMP]]
2338 %notx = xor i8 %x, -1
2339 %cmp = icmp sgt i8 %notx, %y
2340 %cmpeq = icmp ne i8 %x, 127
2341 %r = and i1 %cmpeq, %cmp
2345 define i1 @sgt_swap_and_not_min_not_op(i8 %x, i8 %y) {
2346 ; CHECK-LABEL: @sgt_swap_and_not_min_not_op(
2347 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2348 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
2349 ; CHECK-NEXT: ret i1 [[CMP]]
2351 %notx = xor i8 %x, -1
2352 %cmp = icmp slt i8 %y, %notx
2353 %cmpeq = icmp ne i8 %x, 127
2354 %r = and i1 %cmp, %cmpeq
2358 define i1 @sgt_swap_and_not_min_commute_not_op(i8 %x, i8 %y) {
2359 ; CHECK-LABEL: @sgt_swap_and_not_min_commute_not_op(
2360 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2361 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
2362 ; CHECK-NEXT: ret i1 [[CMP]]
2364 %notx = xor i8 %x, -1
2365 %cmp = icmp slt i8 %y, %notx
2366 %cmpeq = icmp ne i8 %x, 127
2367 %r = and i1 %cmpeq, %cmp
2371 define i1 @ugt_and_not_min_not_op(i8 %x, i8 %y) {
2372 ; CHECK-LABEL: @ugt_and_not_min_not_op(
2373 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2374 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
2375 ; CHECK-NEXT: ret i1 [[CMP]]
2377 %notx = xor i8 %x, -1
2378 %cmp = icmp ugt i8 %notx, %y
2379 %cmpeq = icmp ne i8 %x, 255
2380 %r = and i1 %cmp, %cmpeq
2384 define i1 @ugt_and_not_min_commute_not_op(i8 %x, i8 %y) {
2385 ; CHECK-LABEL: @ugt_and_not_min_commute_not_op(
2386 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2387 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
2388 ; CHECK-NEXT: ret i1 [[CMP]]
2390 %notx = xor i8 %x, -1
2391 %cmp = icmp ugt i8 %notx, %y
2392 %cmpeq = icmp ne i8 %x, 255
2393 %r = and i1 %cmpeq, %cmp
2397 define i1 @ugt_swap_and_not_min_not_op(i8 %x, i8 %y) {
2398 ; CHECK-LABEL: @ugt_swap_and_not_min_not_op(
2399 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2400 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[NOTX]]
2401 ; CHECK-NEXT: ret i1 [[CMP]]
2403 %notx = xor i8 %x, -1
2404 %cmp = icmp ult i8 %y, %notx
2405 %cmpeq = icmp ne i8 %x, 255
2406 %r = and i1 %cmp, %cmpeq
2410 define i1 @ugt_swap_and_not_min_commute_not_op(i8 %x, i8 %y) {
2411 ; CHECK-LABEL: @ugt_swap_and_not_min_commute_not_op(
2412 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2413 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[NOTX]]
2414 ; CHECK-NEXT: ret i1 [[CMP]]
2416 %notx = xor i8 %x, -1
2417 %cmp = icmp ult i8 %y, %notx
2418 %cmpeq = icmp ne i8 %x, 255
2419 %r = and i1 %cmpeq, %cmp
2423 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2425 ; (X != MIN) || (!X < Y) --> X != MIN
2427 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2429 define i1 @slt_or_not_max_not_op(i8 %x, i8 %y) {
2430 ; CHECK-LABEL: @slt_or_not_max_not_op(
2431 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2432 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NOTX]], [[Y:%.*]]
2433 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
2434 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2435 ; CHECK-NEXT: ret i1 [[R]]
2437 %notx = xor i8 %x, -1
2438 %cmp = icmp slt i8 %notx, %y
2439 %cmpeq = icmp ne i8 %x, 128
2440 %r = or i1 %cmp, %cmpeq
2444 define i1 @slt_or_not_max_commute_not_op(i8 %x, i8 %y) {
2445 ; CHECK-LABEL: @slt_or_not_max_commute_not_op(
2446 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2447 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[NOTX]], [[Y:%.*]]
2448 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
2449 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2450 ; CHECK-NEXT: ret i1 [[R]]
2452 %notx = xor i8 %x, -1
2453 %cmp = icmp slt i8 %notx, %y
2454 %cmpeq = icmp ne i8 %x, 128
2455 %r = or i1 %cmpeq, %cmp
2459 define i1 @slt_swap_or_not_max_not_op(i8 %x, i8 %y) {
2460 ; CHECK-LABEL: @slt_swap_or_not_max_not_op(
2461 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2462 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
2463 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
2464 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2465 ; CHECK-NEXT: ret i1 [[R]]
2467 %notx = xor i8 %x, -1
2468 %cmp = icmp sgt i8 %y, %notx
2469 %cmpeq = icmp ne i8 %x, 128
2470 %r = or i1 %cmp, %cmpeq
2474 define i1 @slt_swap_or_not_max_commute_not_op(i8 %x, i8 %y) {
2475 ; CHECK-LABEL: @slt_swap_or_not_max_commute_not_op(
2476 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2477 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[Y:%.*]], [[NOTX]]
2478 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -128
2479 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2480 ; CHECK-NEXT: ret i1 [[R]]
2482 %notx = xor i8 %x, -1
2483 %cmp = icmp sgt i8 %y, %notx
2484 %cmpeq = icmp ne i8 %x, 128
2485 %r = or i1 %cmpeq, %cmp
2489 define i1 @ult_or_not_max_not_op(i8 %x, i8 %y) {
2490 ; CHECK-LABEL: @ult_or_not_max_not_op(
2491 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2492 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
2493 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
2494 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2495 ; CHECK-NEXT: ret i1 [[R]]
2497 %notx = xor i8 %x, -1
2498 %cmp = icmp ult i8 %notx, %y
2499 %cmpeq = icmp ne i8 %x, 0
2500 %r = or i1 %cmp, %cmpeq
2504 define i1 @ult_or_not_max_commute_not_op(i8 %x, i8 %y) {
2505 ; CHECK-LABEL: @ult_or_not_max_commute_not_op(
2506 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2507 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[NOTX]], [[Y:%.*]]
2508 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
2509 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2510 ; CHECK-NEXT: ret i1 [[R]]
2512 %notx = xor i8 %x, -1
2513 %cmp = icmp ult i8 %notx, %y
2514 %cmpeq = icmp ne i8 %x, 0
2515 %r = or i1 %cmpeq, %cmp
2519 define i1 @ult_swap_or_not_max_not_op(i8 %x, i8 %y) {
2520 ; CHECK-LABEL: @ult_swap_or_not_max_not_op(
2521 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2522 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
2523 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
2524 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2525 ; CHECK-NEXT: ret i1 [[R]]
2527 %notx = xor i8 %x, -1
2528 %cmp = icmp ugt i8 %y, %notx
2529 %cmpeq = icmp ne i8 %x, 0
2530 %r = or i1 %cmp, %cmpeq
2534 define i1 @ult_swap_or_not_max_commute_not_op(i8 %x, i8 %y) {
2535 ; CHECK-LABEL: @ult_swap_or_not_max_commute_not_op(
2536 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2537 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[Y:%.*]], [[NOTX]]
2538 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 0
2539 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2540 ; CHECK-NEXT: ret i1 [[R]]
2542 %notx = xor i8 %x, -1
2543 %cmp = icmp ugt i8 %y, %notx
2544 %cmpeq = icmp ne i8 %x, 0
2545 %r = or i1 %cmpeq, %cmp
2549 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2551 ; (X != MAX) || (!X > Y) --> X != MAX
2553 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2555 define i1 @sgt_or_not_min_not_op(i8 %x, i8 %y) {
2556 ; CHECK-LABEL: @sgt_or_not_min_not_op(
2557 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2558 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NOTX]], [[Y:%.*]]
2559 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
2560 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2561 ; CHECK-NEXT: ret i1 [[R]]
2563 %notx = xor i8 %x, -1
2564 %cmp = icmp sgt i8 %notx, %y
2565 %cmpeq = icmp ne i8 %x, 127
2566 %r = or i1 %cmp, %cmpeq
2570 define i1 @sgt_or_not_min_commute_not_op(i8 %x, i8 %y) {
2571 ; CHECK-LABEL: @sgt_or_not_min_commute_not_op(
2572 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2573 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8 [[NOTX]], [[Y:%.*]]
2574 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
2575 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2576 ; CHECK-NEXT: ret i1 [[R]]
2578 %notx = xor i8 %x, -1
2579 %cmp = icmp sgt i8 %notx, %y
2580 %cmpeq = icmp ne i8 %x, 127
2581 %r = or i1 %cmpeq, %cmp
2585 define i1 @sgt_swap_or_not_min_not_op(i8 %x, i8 %y) {
2586 ; CHECK-LABEL: @sgt_swap_or_not_min_not_op(
2587 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2588 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
2589 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
2590 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2591 ; CHECK-NEXT: ret i1 [[R]]
2593 %notx = xor i8 %x, -1
2594 %cmp = icmp slt i8 %y, %notx
2595 %cmpeq = icmp ne i8 %x, 127
2596 %r = or i1 %cmp, %cmpeq
2600 define i1 @sgt_swap_or_not_min_commute_not_op(i8 %x, i8 %y) {
2601 ; CHECK-LABEL: @sgt_swap_or_not_min_commute_not_op(
2602 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2603 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i8 [[Y:%.*]], [[NOTX]]
2604 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], 127
2605 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2606 ; CHECK-NEXT: ret i1 [[R]]
2608 %notx = xor i8 %x, -1
2609 %cmp = icmp slt i8 %y, %notx
2610 %cmpeq = icmp ne i8 %x, 127
2611 %r = or i1 %cmpeq, %cmp
2615 define i1 @ugt_or_not_min_not_op(i8 %x, i8 %y) {
2616 ; CHECK-LABEL: @ugt_or_not_min_not_op(
2617 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2618 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
2619 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
2620 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2621 ; CHECK-NEXT: ret i1 [[R]]
2623 %notx = xor i8 %x, -1
2624 %cmp = icmp ugt i8 %notx, %y
2625 %cmpeq = icmp ne i8 %x, 255
2626 %r = or i1 %cmp, %cmpeq
2630 define i1 @ugt_or_not_min_commute_not_op(i8 %x, i8 %y) {
2631 ; CHECK-LABEL: @ugt_or_not_min_commute_not_op(
2632 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2633 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[NOTX]], [[Y:%.*]]
2634 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
2635 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2636 ; CHECK-NEXT: ret i1 [[R]]
2638 %notx = xor i8 %x, -1
2639 %cmp = icmp ugt i8 %notx, %y
2640 %cmpeq = icmp ne i8 %x, 255
2641 %r = or i1 %cmpeq, %cmp
2645 define i1 @ugt_swap_or_not_min_not_op(i8 %x, i8 %y) {
2646 ; CHECK-LABEL: @ugt_swap_or_not_min_not_op(
2647 ; CHECK-NEXT: [[NOTX:%.*]] = xor i8 [[X:%.*]], -1
2648 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[Y:%.*]], [[NOTX]]
2649 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8 [[X]], -1
2650 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMP]], [[CMPEQ]]
2651 ; CHECK-NEXT: ret i1 [[R]]
2653 %notx = xor i8 %x, -1
2654 %cmp = icmp ult i8 %y, %notx
2655 %cmpeq = icmp ne i8 %x, 255
2656 %r = or i1 %cmp, %cmpeq
2660 define i1 @ugt_swap_or_not_min_commute_not_op(i823 %x, i823 %y) {
2661 ; CHECK-LABEL: @ugt_swap_or_not_min_commute_not_op(
2662 ; CHECK-NEXT: [[NOTX:%.*]] = xor i823 [[X:%.*]], -1
2663 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i823 [[Y:%.*]], [[NOTX]]
2664 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823 [[X]], 255
2665 ; CHECK-NEXT: [[R:%.*]] = or i1 [[CMPEQ]], [[CMP]]
2666 ; CHECK-NEXT: ret i1 [[R]]
2668 %notx = xor i823 %x, -1
2669 %cmp = icmp ult i823 %y, %notx
2670 %cmpeq = icmp ne i823 %x, 255
2671 %r = or i1 %cmpeq, %cmp