1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; This is a specialization of generic folds for min/max values targeted to the
6 ; Related tests for non-pointer types should be included in another file.
8 ; There are 6 basic patterns (or 3 with DeMorganized equivalent) with
9 ; 2 (commute logic op) *
10 ; 2 (swap compare operands) *
11 ; variations for a total of 24 tests.
13 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 ; (X == null) && (X > Y) --> false
17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
19 define i1 @ugt_and_min(i8* %x, i8* %y) {
20 ; CHECK-LABEL: @ugt_and_min(
21 ; CHECK-NEXT: ret i1 false
23 %cmp = icmp ugt i8* %x, %y
24 %cmpeq = icmp eq i8* %x, null
25 %r = and i1 %cmp, %cmpeq
29 define i1 @ugt_and_min_logical(i8* %x, i8* %y) {
30 ; CHECK-LABEL: @ugt_and_min_logical(
31 ; CHECK-NEXT: ret i1 false
33 %cmp = icmp ugt i8* %x, %y
34 %cmpeq = icmp eq i8* %x, null
35 %r = select i1 %cmp, i1 %cmpeq, i1 false
39 define i1 @ugt_and_min_commute(<2 x i8>* %x, <2 x i8>* %y) {
40 ; CHECK-LABEL: @ugt_and_min_commute(
41 ; CHECK-NEXT: ret i1 false
43 %cmp = icmp ugt <2 x i8>* %x, %y
44 %cmpeq = icmp eq <2 x i8>* %x, null
45 %r = and i1 %cmpeq, %cmp
49 define i1 @ugt_and_min_commute_logical(<2 x i8>* %x, <2 x i8>* %y) {
50 ; CHECK-LABEL: @ugt_and_min_commute_logical(
51 ; CHECK-NEXT: ret i1 false
53 %cmp = icmp ugt <2 x i8>* %x, %y
54 %cmpeq = icmp eq <2 x i8>* %x, null
55 %r = select i1 %cmpeq, i1 %cmp, i1 false
59 define i1 @ugt_swap_and_min(i8* %x, i8* %y) {
60 ; CHECK-LABEL: @ugt_swap_and_min(
61 ; CHECK-NEXT: ret i1 false
63 %cmp = icmp ult i8* %y, %x
64 %cmpeq = icmp eq i8* %x, null
65 %r = and i1 %cmp, %cmpeq
69 define i1 @ugt_swap_and_min_logical(i8* %x, i8* %y) {
70 ; CHECK-LABEL: @ugt_swap_and_min_logical(
71 ; CHECK-NEXT: ret i1 false
73 %cmp = icmp ult i8* %y, %x
74 %cmpeq = icmp eq i8* %x, null
75 %r = select i1 %cmp, i1 %cmpeq, i1 false
79 define i1 @ugt_swap_and_min_commute(i8* %x, i8* %y) {
80 ; CHECK-LABEL: @ugt_swap_and_min_commute(
81 ; CHECK-NEXT: ret i1 false
83 %cmp = icmp ult i8* %y, %x
84 %cmpeq = icmp eq i8* %x, null
85 %r = and i1 %cmpeq, %cmp
89 define i1 @ugt_swap_and_min_commute_logical(i8* %x, i8* %y) {
90 ; CHECK-LABEL: @ugt_swap_and_min_commute_logical(
91 ; CHECK-NEXT: ret i1 false
93 %cmp = icmp ult i8* %y, %x
94 %cmpeq = icmp eq i8* %x, null
95 %r = select i1 %cmpeq, i1 %cmp, i1 false
99 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
101 ; (X != null) || (X <= Y) --> true
103 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
105 define i1 @ule_or_not_min(i427* %x, i427* %y) {
106 ; CHECK-LABEL: @ule_or_not_min(
107 ; CHECK-NEXT: ret i1 true
109 %cmp = icmp ule i427* %x, %y
110 %cmpeq = icmp ne i427* %x, null
111 %r = or i1 %cmp, %cmpeq
115 define i1 @ule_or_not_min_logical(i427* %x, i427* %y) {
116 ; CHECK-LABEL: @ule_or_not_min_logical(
117 ; CHECK-NEXT: ret i1 true
119 %cmp = icmp ule i427* %x, %y
120 %cmpeq = icmp ne i427* %x, null
121 %r = select i1 %cmp, i1 true, i1 %cmpeq
125 define i1 @ule_or_not_min_commute(<3 x i9>* %x, <3 x i9>* %y) {
126 ; CHECK-LABEL: @ule_or_not_min_commute(
127 ; CHECK-NEXT: ret i1 true
129 %cmp = icmp ule <3 x i9>* %x, %y
130 %cmpeq = icmp ne <3 x i9>* %x, null
131 %r = or i1 %cmpeq, %cmp
135 define i1 @ule_or_not_min_commute_logical(<3 x i9>* %x, <3 x i9>* %y) {
136 ; CHECK-LABEL: @ule_or_not_min_commute_logical(
137 ; CHECK-NEXT: ret i1 true
139 %cmp = icmp ule <3 x i9>* %x, %y
140 %cmpeq = icmp ne <3 x i9>* %x, null
141 %r = select i1 %cmpeq, i1 true, i1 %cmp
145 define i1 @ule_swap_or_not_min(i8* %x, i8* %y) {
146 ; CHECK-LABEL: @ule_swap_or_not_min(
147 ; CHECK-NEXT: ret i1 true
149 %cmp = icmp uge i8* %y, %x
150 %cmpeq = icmp ne i8* %x, null
151 %r = or i1 %cmp, %cmpeq
155 define i1 @ule_swap_or_not_min_logical(i8* %x, i8* %y) {
156 ; CHECK-LABEL: @ule_swap_or_not_min_logical(
157 ; CHECK-NEXT: ret i1 true
159 %cmp = icmp uge i8* %y, %x
160 %cmpeq = icmp ne i8* %x, null
161 %r = select i1 %cmp, i1 true, i1 %cmpeq
165 define i1 @ule_swap_or_not_min_commute(i8* %x, i8* %y) {
166 ; CHECK-LABEL: @ule_swap_or_not_min_commute(
167 ; CHECK-NEXT: ret i1 true
169 %cmp = icmp uge i8* %y, %x
170 %cmpeq = icmp ne i8* %x, null
171 %r = or i1 %cmpeq, %cmp
175 define i1 @ule_swap_or_not_min_commute_logical(i8* %x, i8* %y) {
176 ; CHECK-LABEL: @ule_swap_or_not_min_commute_logical(
177 ; CHECK-NEXT: ret i1 true
179 %cmp = icmp uge i8* %y, %x
180 %cmpeq = icmp ne i8* %x, null
181 %r = select i1 %cmpeq, i1 true, i1 %cmp
185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
187 ; (X == null) && (X <= Y) --> X == null
189 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
191 define i1 @ule_and_min(i8* %x, i8* %y) {
192 ; CHECK-LABEL: @ule_and_min(
193 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
194 ; CHECK-NEXT: ret i1 [[CMPEQ]]
196 %cmp = icmp ule i8* %x, %y
197 %cmpeq = icmp eq i8* %x, null
198 %r = and i1 %cmp, %cmpeq
202 define i1 @ule_and_min_logical(i8* %x, i8* %y) {
203 ; CHECK-LABEL: @ule_and_min_logical(
204 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
205 ; CHECK-NEXT: ret i1 [[CMPEQ]]
207 %cmp = icmp ule i8* %x, %y
208 %cmpeq = icmp eq i8* %x, null
209 %r = select i1 %cmp, i1 %cmpeq, i1 false
213 define i1 @ule_and_min_commute(i8* %x, i8* %y) {
214 ; CHECK-LABEL: @ule_and_min_commute(
215 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
216 ; CHECK-NEXT: ret i1 [[CMPEQ]]
218 %cmp = icmp ule i8* %x, %y
219 %cmpeq = icmp eq i8* %x, null
220 %r = and i1 %cmpeq, %cmp
224 define i1 @ule_and_min_commute_logical(i8* %x, i8* %y) {
225 ; CHECK-LABEL: @ule_and_min_commute_logical(
226 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
227 ; CHECK-NEXT: ret i1 [[CMPEQ]]
229 %cmp = icmp ule i8* %x, %y
230 %cmpeq = icmp eq i8* %x, null
231 %r = select i1 %cmpeq, i1 %cmp, i1 false
235 define i1 @ule_swap_and_min(i8* %x, i8* %y) {
236 ; CHECK-LABEL: @ule_swap_and_min(
237 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
238 ; CHECK-NEXT: ret i1 [[CMPEQ]]
240 %cmp = icmp uge i8* %y, %x
241 %cmpeq = icmp eq i8* %x, null
242 %r = and i1 %cmp, %cmpeq
246 define i1 @ule_swap_and_min_logical(i8* %x, i8* %y) {
247 ; CHECK-LABEL: @ule_swap_and_min_logical(
248 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
249 ; CHECK-NEXT: ret i1 [[CMPEQ]]
251 %cmp = icmp uge i8* %y, %x
252 %cmpeq = icmp eq i8* %x, null
253 %r = select i1 %cmp, i1 %cmpeq, i1 false
257 define i1 @ule_swap_and_min_commute(i8* %x, i8* %y) {
258 ; CHECK-LABEL: @ule_swap_and_min_commute(
259 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
260 ; CHECK-NEXT: ret i1 [[CMPEQ]]
262 %cmp = icmp uge i8* %y, %x
263 %cmpeq = icmp eq i8* %x, null
264 %r = and i1 %cmpeq, %cmp
268 define i1 @ule_swap_and_min_commute_logical(i8* %x, i8* %y) {
269 ; CHECK-LABEL: @ule_swap_and_min_commute_logical(
270 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
271 ; CHECK-NEXT: ret i1 [[CMPEQ]]
273 %cmp = icmp uge i8* %y, %x
274 %cmpeq = icmp eq i8* %x, null
275 %r = select i1 %cmpeq, i1 %cmp, i1 false
279 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
281 ; (X == null) || (X <= Y) --> X <= Y
283 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
285 define i1 @ule_or_min(i8* %x, i8* %y) {
286 ; CHECK-LABEL: @ule_or_min(
287 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8* [[X:%.*]], [[Y:%.*]]
288 ; CHECK-NEXT: ret i1 [[CMP]]
290 %cmp = icmp ule i8* %x, %y
291 %cmpeq = icmp eq i8* %x, null
292 %r = or i1 %cmp, %cmpeq
296 define i1 @ule_or_min_logical(i8* %x, i8* %y) {
297 ; CHECK-LABEL: @ule_or_min_logical(
298 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8* [[X:%.*]], [[Y:%.*]]
299 ; CHECK-NEXT: ret i1 [[CMP]]
301 %cmp = icmp ule i8* %x, %y
302 %cmpeq = icmp eq i8* %x, null
303 %r = select i1 %cmp, i1 true, i1 %cmpeq
307 define i1 @ule_or_min_commute(i8* %x, i8* %y) {
308 ; CHECK-LABEL: @ule_or_min_commute(
309 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8* [[X:%.*]], [[Y:%.*]]
310 ; CHECK-NEXT: ret i1 [[CMP]]
312 %cmp = icmp ule i8* %x, %y
313 %cmpeq = icmp eq i8* %x, null
314 %r = or i1 %cmpeq, %cmp
318 define i1 @ule_or_min_commute_logical(i8* %x, i8* %y) {
319 ; CHECK-LABEL: @ule_or_min_commute_logical(
320 ; CHECK-NEXT: [[CMP:%.*]] = icmp ule i8* [[X:%.*]], [[Y:%.*]]
321 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X]], null
322 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
323 ; CHECK-NEXT: ret i1 [[R]]
325 %cmp = icmp ule i8* %x, %y
326 %cmpeq = icmp eq i8* %x, null
327 %r = select i1 %cmpeq, i1 true, i1 %cmp
331 define i1 @ule_swap_or_min(i8* %x, i8* %y) {
332 ; CHECK-LABEL: @ule_swap_or_min(
333 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8* [[Y:%.*]], [[X:%.*]]
334 ; CHECK-NEXT: ret i1 [[CMP]]
336 %cmp = icmp uge i8* %y, %x
337 %cmpeq = icmp eq i8* %x, null
338 %r = or i1 %cmp, %cmpeq
342 define i1 @ule_swap_or_min_logical(i8* %x, i8* %y) {
343 ; CHECK-LABEL: @ule_swap_or_min_logical(
344 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8* [[Y:%.*]], [[X:%.*]]
345 ; CHECK-NEXT: ret i1 [[CMP]]
347 %cmp = icmp uge i8* %y, %x
348 %cmpeq = icmp eq i8* %x, null
349 %r = select i1 %cmp, i1 true, i1 %cmpeq
353 define i1 @ule_swap_or_min_commute(i8* %x, i8* %y) {
354 ; CHECK-LABEL: @ule_swap_or_min_commute(
355 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8* [[Y:%.*]], [[X:%.*]]
356 ; CHECK-NEXT: ret i1 [[CMP]]
358 %cmp = icmp uge i8* %y, %x
359 %cmpeq = icmp eq i8* %x, null
360 %r = or i1 %cmpeq, %cmp
364 define i1 @ule_swap_or_min_commute_logical(i8* %x, i8* %y) {
365 ; CHECK-LABEL: @ule_swap_or_min_commute_logical(
366 ; CHECK-NEXT: [[CMP:%.*]] = icmp uge i8* [[Y:%.*]], [[X:%.*]]
367 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X]], null
368 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 true, i1 [[CMP]]
369 ; CHECK-NEXT: ret i1 [[R]]
371 %cmp = icmp uge i8* %y, %x
372 %cmpeq = icmp eq i8* %x, null
373 %r = select i1 %cmpeq, i1 true, i1 %cmp
377 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
379 ; (X != null) && (X > Y) --> X > Y
381 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
383 define i1 @ugt_and_not_min(i8* %x, i8* %y) {
384 ; CHECK-LABEL: @ugt_and_not_min(
385 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8* [[X:%.*]], [[Y:%.*]]
386 ; CHECK-NEXT: ret i1 [[CMP]]
388 %cmp = icmp ugt i8* %x, %y
389 %cmpeq = icmp ne i8* %x, null
390 %r = and i1 %cmp, %cmpeq
394 define i1 @ugt_and_not_min_logical(i8* %x, i8* %y) {
395 ; CHECK-LABEL: @ugt_and_not_min_logical(
396 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8* [[X:%.*]], [[Y:%.*]]
397 ; CHECK-NEXT: ret i1 [[CMP]]
399 %cmp = icmp ugt i8* %x, %y
400 %cmpeq = icmp ne i8* %x, null
401 %r = select i1 %cmp, i1 %cmpeq, i1 false
405 define i1 @ugt_and_not_min_commute(i8* %x, i8* %y) {
406 ; CHECK-LABEL: @ugt_and_not_min_commute(
407 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8* [[X:%.*]], [[Y:%.*]]
408 ; CHECK-NEXT: ret i1 [[CMP]]
410 %cmp = icmp ugt i8* %x, %y
411 %cmpeq = icmp ne i8* %x, null
412 %r = and i1 %cmpeq, %cmp
416 define i1 @ugt_and_not_min_commute_logical(i8* %x, i8* %y) {
417 ; CHECK-LABEL: @ugt_and_not_min_commute_logical(
418 ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8* [[X:%.*]], [[Y:%.*]]
419 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X]], null
420 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
421 ; CHECK-NEXT: ret i1 [[R]]
423 %cmp = icmp ugt i8* %x, %y
424 %cmpeq = icmp ne i8* %x, null
425 %r = select i1 %cmpeq, i1 %cmp, i1 false
429 define i1 @ugt_swap_and_not_min(i8* %x, i8* %y) {
430 ; CHECK-LABEL: @ugt_swap_and_not_min(
431 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8* [[Y:%.*]], [[X:%.*]]
432 ; CHECK-NEXT: ret i1 [[CMP]]
434 %cmp = icmp ult i8* %y, %x
435 %cmpeq = icmp ne i8* %x, null
436 %r = and i1 %cmp, %cmpeq
440 define i1 @ugt_swap_and_not_min_logical(i8* %x, i8* %y) {
441 ; CHECK-LABEL: @ugt_swap_and_not_min_logical(
442 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8* [[Y:%.*]], [[X:%.*]]
443 ; CHECK-NEXT: ret i1 [[CMP]]
445 %cmp = icmp ult i8* %y, %x
446 %cmpeq = icmp ne i8* %x, null
447 %r = select i1 %cmp, i1 %cmpeq, i1 false
451 define i1 @ugt_swap_and_not_min_commute(i8* %x, i8* %y) {
452 ; CHECK-LABEL: @ugt_swap_and_not_min_commute(
453 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8* [[Y:%.*]], [[X:%.*]]
454 ; CHECK-NEXT: ret i1 [[CMP]]
456 %cmp = icmp ult i8* %y, %x
457 %cmpeq = icmp ne i8* %x, null
458 %r = and i1 %cmpeq, %cmp
462 define i1 @ugt_swap_and_not_min_commute_logical(i8* %x, i8* %y) {
463 ; CHECK-LABEL: @ugt_swap_and_not_min_commute_logical(
464 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8* [[Y:%.*]], [[X:%.*]]
465 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X]], null
466 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
467 ; CHECK-NEXT: ret i1 [[R]]
469 %cmp = icmp ult i8* %y, %x
470 %cmpeq = icmp ne i8* %x, null
471 %r = select i1 %cmpeq, i1 %cmp, i1 false
475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
477 ; (X != null) || (X > Y) --> X != null
479 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
481 define i1 @ugt_or_not_min(i8* %x, i8* %y) {
482 ; CHECK-LABEL: @ugt_or_not_min(
483 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
484 ; CHECK-NEXT: ret i1 [[CMPEQ]]
486 %cmp = icmp ugt i8* %x, %y
487 %cmpeq = icmp ne i8* %x, null
488 %r = or i1 %cmp, %cmpeq
492 define i1 @ugt_or_not_min_logical(i8* %x, i8* %y) {
493 ; CHECK-LABEL: @ugt_or_not_min_logical(
494 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
495 ; CHECK-NEXT: ret i1 [[CMPEQ]]
497 %cmp = icmp ugt i8* %x, %y
498 %cmpeq = icmp ne i8* %x, null
499 %r = select i1 %cmp, i1 true, i1 %cmpeq
503 define i1 @ugt_or_not_min_commute(i8* %x, i8* %y) {
504 ; CHECK-LABEL: @ugt_or_not_min_commute(
505 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
506 ; CHECK-NEXT: ret i1 [[CMPEQ]]
508 %cmp = icmp ugt i8* %x, %y
509 %cmpeq = icmp ne i8* %x, null
510 %r = or i1 %cmpeq, %cmp
514 define i1 @ugt_or_not_min_commute_logical(i8* %x, i8* %y) {
515 ; CHECK-LABEL: @ugt_or_not_min_commute_logical(
516 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
517 ; CHECK-NEXT: ret i1 [[CMPEQ]]
519 %cmp = icmp ugt i8* %x, %y
520 %cmpeq = icmp ne i8* %x, null
521 %r = select i1 %cmpeq, i1 true, i1 %cmp
525 define i1 @ugt_swap_or_not_min(i8* %x, i8* %y) {
526 ; CHECK-LABEL: @ugt_swap_or_not_min(
527 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
528 ; CHECK-NEXT: ret i1 [[CMPEQ]]
530 %cmp = icmp ult i8* %y, %x
531 %cmpeq = icmp ne i8* %x, null
532 %r = or i1 %cmp, %cmpeq
536 define i1 @ugt_swap_or_not_min_logical(i8* %x, i8* %y) {
537 ; CHECK-LABEL: @ugt_swap_or_not_min_logical(
538 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
539 ; CHECK-NEXT: ret i1 [[CMPEQ]]
541 %cmp = icmp ult i8* %y, %x
542 %cmpeq = icmp ne i8* %x, null
543 %r = select i1 %cmp, i1 true, i1 %cmpeq
547 define i1 @ugt_swap_or_not_min_commute(i823* %x, i823* %y) {
548 ; CHECK-LABEL: @ugt_swap_or_not_min_commute(
549 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823* [[X:%.*]], null
550 ; CHECK-NEXT: ret i1 [[CMPEQ]]
552 %cmp = icmp ult i823* %y, %x
553 %cmpeq = icmp ne i823* %x, null
554 %r = or i1 %cmpeq, %cmp
558 define i1 @ugt_swap_or_not_min_commute_logical(i823* %x, i823* %y) {
559 ; CHECK-LABEL: @ugt_swap_or_not_min_commute_logical(
560 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i823* [[X:%.*]], null
561 ; CHECK-NEXT: ret i1 [[CMPEQ]]
563 %cmp = icmp ult i823* %y, %x
564 %cmpeq = icmp ne i823* %x, null
565 %r = select i1 %cmpeq, i1 true, i1 %cmp
569 define i1 @sgt_and_min(i9* %x, i9* %y) {
570 ; CHECK-LABEL: @sgt_and_min(
571 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i9* [[X:%.*]], null
572 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i9* [[Y:%.*]], null
573 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CMPEQ]], [[TMP1]]
574 ; CHECK-NEXT: ret i1 [[TMP2]]
576 %cmp = icmp sgt i9* %x, %y
577 %cmpeq = icmp eq i9* %x, null
578 %r = and i1 %cmp, %cmpeq
582 define i1 @sgt_and_min_logical(i9* %x, i9* %y) {
583 ; CHECK-LABEL: @sgt_and_min_logical(
584 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i9* [[X:%.*]], null
585 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i9* [[Y:%.*]], null
586 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CMPEQ]], [[TMP1]]
587 ; CHECK-NEXT: ret i1 [[TMP2]]
589 %cmp = icmp sgt i9* %x, %y
590 %cmpeq = icmp eq i9* %x, null
591 %r = select i1 %cmp, i1 %cmpeq, i1 false
595 define i1 @sle_or_not_min(i427* %x, i427* %y) {
596 ; CHECK-LABEL: @sle_or_not_min(
597 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i427* [[X:%.*]], null
598 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sge i427* [[Y:%.*]], null
599 ; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[CMPEQ]], [[TMP1]]
600 ; CHECK-NEXT: ret i1 [[TMP2]]
602 %cmp = icmp sle i427* %x, %y
603 %cmpeq = icmp ne i427* %x, null
604 %r = or i1 %cmp, %cmpeq
608 define i1 @sle_or_not_min_logical(i427* %x, i427* %y) {
609 ; CHECK-LABEL: @sle_or_not_min_logical(
610 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i427* [[X:%.*]], null
611 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sge i427* [[Y:%.*]], null
612 ; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[CMPEQ]], [[TMP1]]
613 ; CHECK-NEXT: ret i1 [[TMP2]]
615 %cmp = icmp sle i427* %x, %y
616 %cmpeq = icmp ne i427* %x, null
617 %r = select i1 %cmp, i1 true, i1 %cmpeq
621 define i1 @sle_and_min(i8* %x, i8* %y) {
622 ; CHECK-LABEL: @sle_and_min(
623 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
624 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sge i8* [[Y:%.*]], null
625 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CMPEQ]], [[TMP1]]
626 ; CHECK-NEXT: ret i1 [[TMP2]]
628 %cmp = icmp sle i8* %x, %y
629 %cmpeq = icmp eq i8* %x, null
630 %r = and i1 %cmp, %cmpeq
634 define i1 @sle_and_min_logical(i8* %x, i8* %y) {
635 ; CHECK-LABEL: @sle_and_min_logical(
636 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[X:%.*]], null
637 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sge i8* [[Y:%.*]], null
638 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CMPEQ]], [[TMP1]]
639 ; CHECK-NEXT: ret i1 [[TMP2]]
641 %cmp = icmp sle i8* %x, %y
642 %cmpeq = icmp eq i8* %x, null
643 %r = select i1 %cmp, i1 %cmpeq, i1 false
647 define i1 @sgt_and_not_min(i8* %x, i8* %y) {
648 ; CHECK-LABEL: @sgt_and_not_min(
649 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8* [[X:%.*]], [[Y:%.*]]
650 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X]], null
651 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
652 ; CHECK-NEXT: ret i1 [[R]]
654 %cmp = icmp sgt i8* %x, %y
655 %cmpeq = icmp ne i8* %x, null
656 %r = and i1 %cmp, %cmpeq
660 define i1 @sgt_and_not_min_logical(i8* %x, i8* %y) {
661 ; CHECK-LABEL: @sgt_and_not_min_logical(
662 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8* [[X:%.*]], [[Y:%.*]]
663 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X]], null
664 ; CHECK-NEXT: [[R:%.*]] = and i1 [[CMP]], [[CMPEQ]]
665 ; CHECK-NEXT: ret i1 [[R]]
667 %cmp = icmp sgt i8* %x, %y
668 %cmpeq = icmp ne i8* %x, null
669 %r = select i1 %cmp, i1 %cmpeq, i1 false
673 define i1 @sgt_or_not_min(i8* %x, i8* %y) {
674 ; CHECK-LABEL: @sgt_or_not_min(
675 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
676 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8* [[Y:%.*]], null
677 ; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[CMPEQ]], [[TMP1]]
678 ; CHECK-NEXT: ret i1 [[TMP2]]
680 %cmp = icmp sgt i8* %x, %y
681 %cmpeq = icmp ne i8* %x, null
682 %r = or i1 %cmp, %cmpeq
686 define i1 @sgt_or_not_min_logical(i8* %x, i8* %y) {
687 ; CHECK-LABEL: @sgt_or_not_min_logical(
688 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp ne i8* [[X:%.*]], null
689 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8* [[Y:%.*]], null
690 ; CHECK-NEXT: [[TMP2:%.*]] = or i1 [[CMPEQ]], [[TMP1]]
691 ; CHECK-NEXT: ret i1 [[TMP2]]
693 %cmp = icmp sgt i8* %x, %y
694 %cmpeq = icmp ne i8* %x, null
695 %r = select i1 %cmp, i1 true, i1 %cmpeq
699 define i1 @slt_and_min(i8* %a, i8* %b) {
700 ; CHECK-LABEL: @slt_and_min(
701 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[A:%.*]], null
702 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8* [[B:%.*]], null
703 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CMPEQ]], [[TMP1]]
704 ; CHECK-NEXT: ret i1 [[TMP2]]
706 %cmpeq = icmp eq i8* %a, null
707 %cmp = icmp slt i8* %a, %b
708 %r = and i1 %cmpeq, %cmp
712 define i1 @slt_and_min_logical(i8* %a, i8* %b) {
713 ; CHECK-LABEL: @slt_and_min_logical(
714 ; CHECK-NEXT: [[CMPEQ:%.*]] = icmp eq i8* [[A:%.*]], null
715 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i8* [[B:%.*]], null
716 ; CHECK-NEXT: [[R:%.*]] = select i1 [[CMPEQ]], i1 [[CMP]], i1 false
717 ; CHECK-NEXT: ret i1 [[R]]
719 %cmpeq = icmp eq i8* %a, null
720 %cmp = icmp slt i8* %a, %b
721 %r = select i1 %cmpeq, i1 %cmp, i1 false