llvm.org GIT mirror llvm / 02d8347
[InstSimplify] add folds for and-of-icmps with same operands All of these (and a few more) are already handled by InstCombine, but we shouldn't have to wait until then to simplify these because they're cheap to deal with here in InstSimplify. This is the 'and' sibling of the earlier 'or' patch: https://reviews.llvm.org/rL288833 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288841 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
2 changed file(s) with 91 addition(s) and 197 deletion(s). Raw diff Collapse all Expand all
15171517 return nullptr;
15181518 }
15191519
1520 /// Commuted variants are assumed to be handled by calling this function again
1521 /// with the parameters swapped.
1522 static Value *simplifyAndOfICmpsWithSameOperands(ICmpInst *Op0, ICmpInst *Op1) {
1523 ICmpInst::Predicate Pred0, Pred1;
1524 Value *A ,*B;
1525 match(Op0, m_ICmp(Pred0, m_Value(A), m_Value(B)));
1526 if (match(Op1, m_ICmp(Pred1, m_Specific(B), m_Specific(A))))
1527 Op1->swapOperands();
1528
1529 if (!match(Op1, m_ICmp(Pred1, m_Specific(A), m_Specific(B))))
1530 return nullptr;
1531
1532 // We have (icmp Pred0, A, B) & (icmp Pred1, A, B).
1533 // If Op1 is always implied true by Op0, then Op0 is a subset of Op1, and we
1534 // can eliminate Op1 from this 'and'.
1535 if (ICmpInst::isImpliedTrueByMatchingCmp(Pred0, Pred1))
1536 return Op0;
1537
1538 // Check for any combination of predicates that are guaranteed to be disjoint.
1539 if ((Pred0 == ICmpInst::getInversePredicate(Pred1)) ||
1540 (Pred0 == ICmpInst::ICMP_EQ && ICmpInst::isFalseWhenEqual(Pred1)) ||
1541 (Pred0 == ICmpInst::ICMP_SLT && Pred1 == ICmpInst::ICMP_SGT) ||
1542 (Pred0 == ICmpInst::ICMP_ULT && Pred1 == ICmpInst::ICMP_UGT))
1543 return getFalse(Op0->getType());
1544
1545 return nullptr;
1546 }
1547
1548 /// Commuted variants are assumed to be handled by calling this function again
1549 /// with the parameters swapped.
15201550 static Value *SimplifyAndOfICmps(ICmpInst *Op0, ICmpInst *Op1) {
15211551 if (Value *X = simplifyUnsignedRangeCheck(Op0, Op1, /*IsAnd=*/true))
1552 return X;
1553
1554 if (Value *X = simplifyAndOfICmpsWithSameOperands(Op0, Op1))
15221555 return X;
15231556
15241557 // Look for this pattern: (icmp V, C0) & (icmp V, C1)).
66 define i1 @eq_eq(i8 %a, i8 %b) {
77 ; CHECK-LABEL: @eq_eq(
88 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
9 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
10 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
11 ; CHECK-NEXT: ret i1 [[AND]]
9 ; CHECK-NEXT: ret i1 [[CMP1]]
1210 ;
1311 %cmp1 = icmp eq i8 %a, %b
1412 %cmp2 = icmp eq i8 %a, %b
1816
1917 define i1 @eq_ne(i8 %a, i8 %b) {
2018 ; CHECK-LABEL: @eq_ne(
21 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
22 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
23 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
24 ; CHECK-NEXT: ret i1 [[AND]]
19 ; CHECK-NEXT: ret i1 false
2520 ;
2621 %cmp1 = icmp eq i8 %a, %b
2722 %cmp2 = icmp ne i8 %a, %b
3227 define i1 @eq_sge(i8 %a, i8 %b) {
3328 ; CHECK-LABEL: @eq_sge(
3429 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
35 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b
36 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
37 ; CHECK-NEXT: ret i1 [[AND]]
30 ; CHECK-NEXT: ret i1 [[CMP1]]
3831 ;
3932 %cmp1 = icmp eq i8 %a, %b
4033 %cmp2 = icmp sge i8 %a, %b
4437
4538 define i1 @eq_sgt(i8 %a, i8 %b) {
4639 ; CHECK-LABEL: @eq_sgt(
47 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
48 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
49 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
50 ; CHECK-NEXT: ret i1 [[AND]]
40 ; CHECK-NEXT: ret i1 false
5141 ;
5242 %cmp1 = icmp eq i8 %a, %b
5343 %cmp2 = icmp sgt i8 %a, %b
5848 define i1 @eq_sle(i8 %a, i8 %b) {
5949 ; CHECK-LABEL: @eq_sle(
6050 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
61 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b
62 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
63 ; CHECK-NEXT: ret i1 [[AND]]
51 ; CHECK-NEXT: ret i1 [[CMP1]]
6452 ;
6553 %cmp1 = icmp eq i8 %a, %b
6654 %cmp2 = icmp sle i8 %a, %b
7058
7159 define i1 @eq_slt(i8 %a, i8 %b) {
7260 ; CHECK-LABEL: @eq_slt(
73 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
74 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
75 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
76 ; CHECK-NEXT: ret i1 [[AND]]
61 ; CHECK-NEXT: ret i1 false
7762 ;
7863 %cmp1 = icmp eq i8 %a, %b
7964 %cmp2 = icmp slt i8 %a, %b
8469 define i1 @eq_uge(i8 %a, i8 %b) {
8570 ; CHECK-LABEL: @eq_uge(
8671 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
87 ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b
88 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
89 ; CHECK-NEXT: ret i1 [[AND]]
72 ; CHECK-NEXT: ret i1 [[CMP1]]
9073 ;
9174 %cmp1 = icmp eq i8 %a, %b
9275 %cmp2 = icmp uge i8 %a, %b
9679
9780 define i1 @eq_ugt(i8 %a, i8 %b) {
9881 ; CHECK-LABEL: @eq_ugt(
99 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
100 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
101 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
102 ; CHECK-NEXT: ret i1 [[AND]]
82 ; CHECK-NEXT: ret i1 false
10383 ;
10484 %cmp1 = icmp eq i8 %a, %b
10585 %cmp2 = icmp ugt i8 %a, %b
11090 define i1 @eq_ule(i8 %a, i8 %b) {
11191 ; CHECK-LABEL: @eq_ule(
11292 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
113 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b
114 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
115 ; CHECK-NEXT: ret i1 [[AND]]
93 ; CHECK-NEXT: ret i1 [[CMP1]]
11694 ;
11795 %cmp1 = icmp eq i8 %a, %b
11896 %cmp2 = icmp ule i8 %a, %b
122100
123101 define i1 @eq_ult(i8 %a, i8 %b) {
124102 ; CHECK-LABEL: @eq_ult(
125 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 %a, %b
126 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
127 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
128 ; CHECK-NEXT: ret i1 [[AND]]
103 ; CHECK-NEXT: ret i1 false
129104 ;
130105 %cmp1 = icmp eq i8 %a, %b
131106 %cmp2 = icmp ult i8 %a, %b
137112
138113 define i1 @ne_eq(i8 %a, i8 %b) {
139114 ; CHECK-LABEL: @ne_eq(
140 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
141 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
142 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
143 ; CHECK-NEXT: ret i1 [[AND]]
115 ; CHECK-NEXT: ret i1 false
144116 ;
145117 %cmp1 = icmp ne i8 %a, %b
146118 %cmp2 = icmp eq i8 %a, %b
151123 define i1 @ne_ne(i8 %a, i8 %b) {
152124 ; CHECK-LABEL: @ne_ne(
153125 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
154 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
155 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
156 ; CHECK-NEXT: ret i1 [[AND]]
126 ; CHECK-NEXT: ret i1 [[CMP1]]
157127 ;
158128 %cmp1 = icmp ne i8 %a, %b
159129 %cmp2 = icmp ne i8 %a, %b
176146
177147 define i1 @ne_sgt(i8 %a, i8 %b) {
178148 ; CHECK-LABEL: @ne_sgt(
179 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
180149 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
181 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
182 ; CHECK-NEXT: ret i1 [[AND]]
150 ; CHECK-NEXT: ret i1 [[CMP2]]
183151 ;
184152 %cmp1 = icmp ne i8 %a, %b
185153 %cmp2 = icmp sgt i8 %a, %b
202170
203171 define i1 @ne_slt(i8 %a, i8 %b) {
204172 ; CHECK-LABEL: @ne_slt(
205 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
206173 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
207 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
208 ; CHECK-NEXT: ret i1 [[AND]]
174 ; CHECK-NEXT: ret i1 [[CMP2]]
209175 ;
210176 %cmp1 = icmp ne i8 %a, %b
211177 %cmp2 = icmp slt i8 %a, %b
228194
229195 define i1 @ne_ugt(i8 %a, i8 %b) {
230196 ; CHECK-LABEL: @ne_ugt(
231 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
232197 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
233 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
234 ; CHECK-NEXT: ret i1 [[AND]]
198 ; CHECK-NEXT: ret i1 [[CMP2]]
235199 ;
236200 %cmp1 = icmp ne i8 %a, %b
237201 %cmp2 = icmp ugt i8 %a, %b
254218
255219 define i1 @ne_ult(i8 %a, i8 %b) {
256220 ; CHECK-LABEL: @ne_ult(
257 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %a, %b
258221 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
259 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
260 ; CHECK-NEXT: ret i1 [[AND]]
222 ; CHECK-NEXT: ret i1 [[CMP2]]
261223 ;
262224 %cmp1 = icmp ne i8 %a, %b
263225 %cmp2 = icmp ult i8 %a, %b
269231
270232 define i1 @sge_eq(i8 %a, i8 %b) {
271233 ; CHECK-LABEL: @sge_eq(
272 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b
273234 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
274 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
275 ; CHECK-NEXT: ret i1 [[AND]]
235 ; CHECK-NEXT: ret i1 [[CMP2]]
276236 ;
277237 %cmp1 = icmp sge i8 %a, %b
278238 %cmp2 = icmp eq i8 %a, %b
296256 define i1 @sge_sge(i8 %a, i8 %b) {
297257 ; CHECK-LABEL: @sge_sge(
298258 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b
299 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b
300 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
301 ; CHECK-NEXT: ret i1 [[AND]]
259 ; CHECK-NEXT: ret i1 [[CMP1]]
302260 ;
303261 %cmp1 = icmp sge i8 %a, %b
304262 %cmp2 = icmp sge i8 %a, %b
308266
309267 define i1 @sge_sgt(i8 %a, i8 %b) {
310268 ; CHECK-LABEL: @sge_sgt(
311 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b
312269 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
313 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
314 ; CHECK-NEXT: ret i1 [[AND]]
270 ; CHECK-NEXT: ret i1 [[CMP2]]
315271 ;
316272 %cmp1 = icmp sge i8 %a, %b
317273 %cmp2 = icmp sgt i8 %a, %b
334290
335291 define i1 @sge_slt(i8 %a, i8 %b) {
336292 ; CHECK-LABEL: @sge_slt(
337 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sge i8 %a, %b
338 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
339 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
340 ; CHECK-NEXT: ret i1 [[AND]]
293 ; CHECK-NEXT: ret i1 false
341294 ;
342295 %cmp1 = icmp sge i8 %a, %b
343296 %cmp2 = icmp slt i8 %a, %b
401354
402355 define i1 @sgt_eq(i8 %a, i8 %b) {
403356 ; CHECK-LABEL: @sgt_eq(
404 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
405 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
406 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
407 ; CHECK-NEXT: ret i1 [[AND]]
357 ; CHECK-NEXT: ret i1 false
408358 ;
409359 %cmp1 = icmp sgt i8 %a, %b
410360 %cmp2 = icmp eq i8 %a, %b
415365 define i1 @sgt_ne(i8 %a, i8 %b) {
416366 ; CHECK-LABEL: @sgt_ne(
417367 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
418 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
419 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
420 ; CHECK-NEXT: ret i1 [[AND]]
368 ; CHECK-NEXT: ret i1 [[CMP1]]
421369 ;
422370 %cmp1 = icmp sgt i8 %a, %b
423371 %cmp2 = icmp ne i8 %a, %b
428376 define i1 @sgt_sge(i8 %a, i8 %b) {
429377 ; CHECK-LABEL: @sgt_sge(
430378 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
431 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b
432 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
433 ; CHECK-NEXT: ret i1 [[AND]]
379 ; CHECK-NEXT: ret i1 [[CMP1]]
434380 ;
435381 %cmp1 = icmp sgt i8 %a, %b
436382 %cmp2 = icmp sge i8 %a, %b
441387 define i1 @sgt_sgt(i8 %a, i8 %b) {
442388 ; CHECK-LABEL: @sgt_sgt(
443389 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
444 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
445 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
446 ; CHECK-NEXT: ret i1 [[AND]]
390 ; CHECK-NEXT: ret i1 [[CMP1]]
447391 ;
448392 %cmp1 = icmp sgt i8 %a, %b
449393 %cmp2 = icmp sgt i8 %a, %b
453397
454398 define i1 @sgt_sle(i8 %a, i8 %b) {
455399 ; CHECK-LABEL: @sgt_sle(
456 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
457 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b
458 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
459 ; CHECK-NEXT: ret i1 [[AND]]
400 ; CHECK-NEXT: ret i1 false
460401 ;
461402 %cmp1 = icmp sgt i8 %a, %b
462403 %cmp2 = icmp sle i8 %a, %b
466407
467408 define i1 @sgt_slt(i8 %a, i8 %b) {
468409 ; CHECK-LABEL: @sgt_slt(
469 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sgt i8 %a, %b
470 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
471 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
472 ; CHECK-NEXT: ret i1 [[AND]]
410 ; CHECK-NEXT: ret i1 false
473411 ;
474412 %cmp1 = icmp sgt i8 %a, %b
475413 %cmp2 = icmp slt i8 %a, %b
533471
534472 define i1 @sle_eq(i8 %a, i8 %b) {
535473 ; CHECK-LABEL: @sle_eq(
536 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b
537474 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
538 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
539 ; CHECK-NEXT: ret i1 [[AND]]
475 ; CHECK-NEXT: ret i1 [[CMP2]]
540476 ;
541477 %cmp1 = icmp sle i8 %a, %b
542478 %cmp2 = icmp eq i8 %a, %b
572508
573509 define i1 @sle_sgt(i8 %a, i8 %b) {
574510 ; CHECK-LABEL: @sle_sgt(
575 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b
576 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
577 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
578 ; CHECK-NEXT: ret i1 [[AND]]
511 ; CHECK-NEXT: ret i1 false
579512 ;
580513 %cmp1 = icmp sle i8 %a, %b
581514 %cmp2 = icmp sgt i8 %a, %b
586519 define i1 @sle_sle(i8 %a, i8 %b) {
587520 ; CHECK-LABEL: @sle_sle(
588521 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b
589 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b
590 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
591 ; CHECK-NEXT: ret i1 [[AND]]
522 ; CHECK-NEXT: ret i1 [[CMP1]]
592523 ;
593524 %cmp1 = icmp sle i8 %a, %b
594525 %cmp2 = icmp sle i8 %a, %b
598529
599530 define i1 @sle_slt(i8 %a, i8 %b) {
600531 ; CHECK-LABEL: @sle_slt(
601 ; CHECK-NEXT: [[CMP1:%.*]] = icmp sle i8 %a, %b
602532 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
603 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
604 ; CHECK-NEXT: ret i1 [[AND]]
533 ; CHECK-NEXT: ret i1 [[CMP2]]
605534 ;
606535 %cmp1 = icmp sle i8 %a, %b
607536 %cmp2 = icmp slt i8 %a, %b
665594
666595 define i1 @slt_eq(i8 %a, i8 %b) {
667596 ; CHECK-LABEL: @slt_eq(
668 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
669 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
670 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
671 ; CHECK-NEXT: ret i1 [[AND]]
597 ; CHECK-NEXT: ret i1 false
672598 ;
673599 %cmp1 = icmp slt i8 %a, %b
674600 %cmp2 = icmp eq i8 %a, %b
679605 define i1 @slt_ne(i8 %a, i8 %b) {
680606 ; CHECK-LABEL: @slt_ne(
681607 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
682 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
683 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
684 ; CHECK-NEXT: ret i1 [[AND]]
608 ; CHECK-NEXT: ret i1 [[CMP1]]
685609 ;
686610 %cmp1 = icmp slt i8 %a, %b
687611 %cmp2 = icmp ne i8 %a, %b
691615
692616 define i1 @slt_sge(i8 %a, i8 %b) {
693617 ; CHECK-LABEL: @slt_sge(
694 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
695 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i8 %a, %b
696 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
697 ; CHECK-NEXT: ret i1 [[AND]]
618 ; CHECK-NEXT: ret i1 false
698619 ;
699620 %cmp1 = icmp slt i8 %a, %b
700621 %cmp2 = icmp sge i8 %a, %b
704625
705626 define i1 @slt_sgt(i8 %a, i8 %b) {
706627 ; CHECK-LABEL: @slt_sgt(
707 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
708 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sgt i8 %a, %b
709 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
710 ; CHECK-NEXT: ret i1 [[AND]]
628 ; CHECK-NEXT: ret i1 false
711629 ;
712630 %cmp1 = icmp slt i8 %a, %b
713631 %cmp2 = icmp sgt i8 %a, %b
718636 define i1 @slt_sle(i8 %a, i8 %b) {
719637 ; CHECK-LABEL: @slt_sle(
720638 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
721 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i8 %a, %b
722 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
723 ; CHECK-NEXT: ret i1 [[AND]]
639 ; CHECK-NEXT: ret i1 [[CMP1]]
724640 ;
725641 %cmp1 = icmp slt i8 %a, %b
726642 %cmp2 = icmp sle i8 %a, %b
731647 define i1 @slt_slt(i8 %a, i8 %b) {
732648 ; CHECK-LABEL: @slt_slt(
733649 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 %a, %b
734 ; CHECK-NEXT: [[CMP2:%.*]] = icmp slt i8 %a, %b
735 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
736 ; CHECK-NEXT: ret i1 [[AND]]
650 ; CHECK-NEXT: ret i1 [[CMP1]]
737651 ;
738652 %cmp1 = icmp slt i8 %a, %b
739653 %cmp2 = icmp slt i8 %a, %b
797711
798712 define i1 @uge_eq(i8 %a, i8 %b) {
799713 ; CHECK-LABEL: @uge_eq(
800 ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b
801714 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
802 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
803 ; CHECK-NEXT: ret i1 [[AND]]
715 ; CHECK-NEXT: ret i1 [[CMP2]]
804716 ;
805717 %cmp1 = icmp uge i8 %a, %b
806718 %cmp2 = icmp eq i8 %a, %b
876788 define i1 @uge_uge(i8 %a, i8 %b) {
877789 ; CHECK-LABEL: @uge_uge(
878790 ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b
879 ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b
880 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
881 ; CHECK-NEXT: ret i1 [[AND]]
791 ; CHECK-NEXT: ret i1 [[CMP1]]
882792 ;
883793 %cmp1 = icmp uge i8 %a, %b
884794 %cmp2 = icmp uge i8 %a, %b
888798
889799 define i1 @uge_ugt(i8 %a, i8 %b) {
890800 ; CHECK-LABEL: @uge_ugt(
891 ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b
892801 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
893 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
894 ; CHECK-NEXT: ret i1 [[AND]]
802 ; CHECK-NEXT: ret i1 [[CMP2]]
895803 ;
896804 %cmp1 = icmp uge i8 %a, %b
897805 %cmp2 = icmp ugt i8 %a, %b
914822
915823 define i1 @uge_ult(i8 %a, i8 %b) {
916824 ; CHECK-LABEL: @uge_ult(
917 ; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i8 %a, %b
918 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
919 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
920 ; CHECK-NEXT: ret i1 [[AND]]
825 ; CHECK-NEXT: ret i1 false
921826 ;
922827 %cmp1 = icmp uge i8 %a, %b
923828 %cmp2 = icmp ult i8 %a, %b
929834
930835 define i1 @ugt_eq(i8 %a, i8 %b) {
931836 ; CHECK-LABEL: @ugt_eq(
932 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
933 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
934 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
935 ; CHECK-NEXT: ret i1 [[AND]]
837 ; CHECK-NEXT: ret i1 false
936838 ;
937839 %cmp1 = icmp ugt i8 %a, %b
938840 %cmp2 = icmp eq i8 %a, %b
943845 define i1 @ugt_ne(i8 %a, i8 %b) {
944846 ; CHECK-LABEL: @ugt_ne(
945847 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
946 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
947 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
948 ; CHECK-NEXT: ret i1 [[AND]]
848 ; CHECK-NEXT: ret i1 [[CMP1]]
949849 ;
950850 %cmp1 = icmp ugt i8 %a, %b
951851 %cmp2 = icmp ne i8 %a, %b
1008908 define i1 @ugt_uge(i8 %a, i8 %b) {
1009909 ; CHECK-LABEL: @ugt_uge(
1010910 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
1011 ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b
1012 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1013 ; CHECK-NEXT: ret i1 [[AND]]
911 ; CHECK-NEXT: ret i1 [[CMP1]]
1014912 ;
1015913 %cmp1 = icmp ugt i8 %a, %b
1016914 %cmp2 = icmp uge i8 %a, %b
1021919 define i1 @ugt_ugt(i8 %a, i8 %b) {
1022920 ; CHECK-LABEL: @ugt_ugt(
1023921 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
1024 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
1025 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1026 ; CHECK-NEXT: ret i1 [[AND]]
922 ; CHECK-NEXT: ret i1 [[CMP1]]
1027923 ;
1028924 %cmp1 = icmp ugt i8 %a, %b
1029925 %cmp2 = icmp ugt i8 %a, %b
1033929
1034930 define i1 @ugt_ule(i8 %a, i8 %b) {
1035931 ; CHECK-LABEL: @ugt_ule(
1036 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
1037 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b
1038 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1039 ; CHECK-NEXT: ret i1 [[AND]]
932 ; CHECK-NEXT: ret i1 false
1040933 ;
1041934 %cmp1 = icmp ugt i8 %a, %b
1042935 %cmp2 = icmp ule i8 %a, %b
1046939
1047940 define i1 @ugt_ult(i8 %a, i8 %b) {
1048941 ; CHECK-LABEL: @ugt_ult(
1049 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i8 %a, %b
1050 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
1051 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1052 ; CHECK-NEXT: ret i1 [[AND]]
942 ; CHECK-NEXT: ret i1 false
1053943 ;
1054944 %cmp1 = icmp ugt i8 %a, %b
1055945 %cmp2 = icmp ult i8 %a, %b
1061951
1062952 define i1 @ule_eq(i8 %a, i8 %b) {
1063953 ; CHECK-LABEL: @ule_eq(
1064 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b
1065954 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
1066 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1067 ; CHECK-NEXT: ret i1 [[AND]]
955 ; CHECK-NEXT: ret i1 [[CMP2]]
1068956 ;
1069957 %cmp1 = icmp ule i8 %a, %b
1070958 %cmp2 = icmp eq i8 %a, %b
11521040
11531041 define i1 @ule_ugt(i8 %a, i8 %b) {
11541042 ; CHECK-LABEL: @ule_ugt(
1155 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b
1156 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
1157 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1158 ; CHECK-NEXT: ret i1 [[AND]]
1043 ; CHECK-NEXT: ret i1 false
11591044 ;
11601045 %cmp1 = icmp ule i8 %a, %b
11611046 %cmp2 = icmp ugt i8 %a, %b
11661051 define i1 @ule_ule(i8 %a, i8 %b) {
11671052 ; CHECK-LABEL: @ule_ule(
11681053 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b
1169 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b
1170 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1171 ; CHECK-NEXT: ret i1 [[AND]]
1054 ; CHECK-NEXT: ret i1 [[CMP1]]
11721055 ;
11731056 %cmp1 = icmp ule i8 %a, %b
11741057 %cmp2 = icmp ule i8 %a, %b
11781061
11791062 define i1 @ule_ult(i8 %a, i8 %b) {
11801063 ; CHECK-LABEL: @ule_ult(
1181 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i8 %a, %b
11821064 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
1183 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1184 ; CHECK-NEXT: ret i1 [[AND]]
1065 ; CHECK-NEXT: ret i1 [[CMP2]]
11851066 ;
11861067 %cmp1 = icmp ule i8 %a, %b
11871068 %cmp2 = icmp ult i8 %a, %b
11931074
11941075 define i1 @ult_eq(i8 %a, i8 %b) {
11951076 ; CHECK-LABEL: @ult_eq(
1196 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1197 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i8 %a, %b
1198 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1199 ; CHECK-NEXT: ret i1 [[AND]]
1077 ; CHECK-NEXT: ret i1 false
12001078 ;
12011079 %cmp1 = icmp ult i8 %a, %b
12021080 %cmp2 = icmp eq i8 %a, %b
12071085 define i1 @ult_ne(i8 %a, i8 %b) {
12081086 ; CHECK-LABEL: @ult_ne(
12091087 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1210 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 %a, %b
1211 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1212 ; CHECK-NEXT: ret i1 [[AND]]
1088 ; CHECK-NEXT: ret i1 [[CMP1]]
12131089 ;
12141090 %cmp1 = icmp ult i8 %a, %b
12151091 %cmp2 = icmp ne i8 %a, %b
12711147
12721148 define i1 @ult_uge(i8 %a, i8 %b) {
12731149 ; CHECK-LABEL: @ult_uge(
1274 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1275 ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i8 %a, %b
1276 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1277 ; CHECK-NEXT: ret i1 [[AND]]
1150 ; CHECK-NEXT: ret i1 false
12781151 ;
12791152 %cmp1 = icmp ult i8 %a, %b
12801153 %cmp2 = icmp uge i8 %a, %b
12841157
12851158 define i1 @ult_ugt(i8 %a, i8 %b) {
12861159 ; CHECK-LABEL: @ult_ugt(
1287 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1288 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i8 %a, %b
1289 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1290 ; CHECK-NEXT: ret i1 [[AND]]
1160 ; CHECK-NEXT: ret i1 false
12911161 ;
12921162 %cmp1 = icmp ult i8 %a, %b
12931163 %cmp2 = icmp ugt i8 %a, %b
12981168 define i1 @ult_ule(i8 %a, i8 %b) {
12991169 ; CHECK-LABEL: @ult_ule(
13001170 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1301 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule i8 %a, %b
1302 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1303 ; CHECK-NEXT: ret i1 [[AND]]
1171 ; CHECK-NEXT: ret i1 [[CMP1]]
13041172 ;
13051173 %cmp1 = icmp ult i8 %a, %b
13061174 %cmp2 = icmp ule i8 %a, %b
13111179 define i1 @ult_ult(i8 %a, i8 %b) {
13121180 ; CHECK-LABEL: @ult_ult(
13131181 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i8 %a, %b
1314 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ult i8 %a, %b
1315 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
1316 ; CHECK-NEXT: ret i1 [[AND]]
1182 ; CHECK-NEXT: ret i1 [[CMP1]]
13171183 ;
13181184 %cmp1 = icmp ult i8 %a, %b
13191185 %cmp2 = icmp ult i8 %a, %b
13251191
13261192 define <2 x i1> @ult_uge_vec(<2 x i8> %a, <2 x i8> %b) {
13271193 ; CHECK-LABEL: @ult_uge_vec(
1328 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i8> %a, %b
1329 ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge <2 x i8> %a, %b
1330 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[CMP1]], [[CMP2]]
1331 ; CHECK-NEXT: ret <2 x i1> [[AND]]
1194 ; CHECK-NEXT: ret <2 x i1> zeroinitializer
13321195 ;
13331196 %cmp1 = icmp ult <2 x i8> %a, %b
13341197 %cmp2 = icmp uge <2 x i8> %a, %b
13391202 define <2 x i1> @ult_ule_vec(<2 x i8> %a, <2 x i8> %b) {
13401203 ; CHECK-LABEL: @ult_ule_vec(
13411204 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult <2 x i8> %a, %b
1342 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ule <2 x i8> %a, %b
1343 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i1> [[CMP1]], [[CMP2]]
1344 ; CHECK-NEXT: ret <2 x i1> [[AND]]
1205 ; CHECK-NEXT: ret <2 x i1> [[CMP1]]
13451206 ;
13461207 %cmp1 = icmp ult <2 x i8> %a, %b
13471208 %cmp2 = icmp ule <2 x i8> %a, %b