llvm.org GIT mirror llvm / dbb2df9
[InstCombine] Add additional saturating add/sub + icmp tests; NFC These test comparisons with saturating add/sub in non-canonical form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349309 91177308-0d34-0410-b5e6-96231b3b80d8 Nikita Popov 9 months ago
1 changed file(s) with 133 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
405405 ret <2 x i8> %y6v
406406 }
407407
408 define i1 @uadd_icmp_known(i8 %a) {
409 ; CHECK-LABEL: @uadd_icmp_known(
408 define i1 @uadd_icmp_op0_known(i8 %a) {
409 ; CHECK-LABEL: @uadd_icmp_op0_known(
410 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 10, i8 [[A:%.*]])
411 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[B]], 10
412 ; CHECK-NEXT: ret i1 [[C]]
413 ;
414 %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
415 %c = icmp uge i8 %b, 10
416 ret i1 %c
417 }
418
419 define i1 @uadd_icmp_op0_unknown(i8 %a) {
420 ; CHECK-LABEL: @uadd_icmp_op0_unknown(
421 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 10, i8 [[A:%.*]])
422 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
423 ; CHECK-NEXT: ret i1 [[C]]
424 ;
425 %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
426 %c = icmp ugt i8 %b, 10
427 ret i1 %c
428 }
429
430 define i1 @uadd_icmp_op1_known(i8 %a) {
431 ; CHECK-LABEL: @uadd_icmp_op1_known(
410432 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 10)
411433 ; CHECK-NEXT: [[C:%.*]] = icmp uge i8 [[B]], 10
412434 ; CHECK-NEXT: ret i1 [[C]]
416438 ret i1 %c
417439 }
418440
419 define i1 @uadd_icmp_unknown(i8 %a) {
420 ; CHECK-LABEL: @uadd_icmp_unknown(
441 define i1 @uadd_icmp_op1_unknown(i8 %a) {
442 ; CHECK-LABEL: @uadd_icmp_op1_unknown(
421443 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 10)
422444 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
423445 ; CHECK-NEXT: ret i1 [[C]]
427449 ret i1 %c
428450 }
429451
430 define i1 @sadd_icmp_pos_known(i8 %a) {
431 ; CHECK-LABEL: @sadd_icmp_pos_known(
452 define i1 @sadd_icmp_op0_pos_known(i8 %a) {
453 ; CHECK-LABEL: @sadd_icmp_op0_pos_known(
454 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 10, i8 [[A:%.*]])
455 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
456 ; CHECK-NEXT: ret i1 [[C]]
457 ;
458 %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
459 %c = icmp sge i8 %b, -118
460 ret i1 %c
461 }
462
463 define i1 @sadd_icmp_op0_pos_unknown(i8 %a) {
464 ; CHECK-LABEL: @sadd_icmp_op0_pos_unknown(
465 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 10, i8 [[A:%.*]])
466 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
467 ; CHECK-NEXT: ret i1 [[C]]
468 ;
469 %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
470 %c = icmp sgt i8 %b, -118
471 ret i1 %c
472 }
473
474 define i1 @sadd_icmp_op0_neg_known(i8 %a) {
475 ; CHECK-LABEL: @sadd_icmp_op0_neg_known(
476 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 -10, i8 [[A:%.*]])
477 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
478 ; CHECK-NEXT: ret i1 [[C]]
479 ;
480 %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
481 %c = icmp sle i8 %b, 117
482 ret i1 %c
483 }
484
485 define i1 @sadd_icmp_op0_neg_unknown(i8 %a) {
486 ; CHECK-LABEL: @sadd_icmp_op0_neg_unknown(
487 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 -10, i8 [[A:%.*]])
488 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
489 ; CHECK-NEXT: ret i1 [[C]]
490 ;
491 %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
492 %c = icmp slt i8 %b, 117
493 ret i1 %c
494 }
495
496 define i1 @sadd_icmp_op1_pos_known(i8 %a) {
497 ; CHECK-LABEL: @sadd_icmp_op1_pos_known(
432498 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 10)
433499 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
434500 ; CHECK-NEXT: ret i1 [[C]]
438504 ret i1 %c
439505 }
440506
441 define i1 @sadd_icmp_pos_unknown(i8 %a) {
442 ; CHECK-LABEL: @sadd_icmp_pos_unknown(
507 define i1 @sadd_icmp_op1_pos_unknown(i8 %a) {
508 ; CHECK-LABEL: @sadd_icmp_op1_pos_unknown(
443509 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 10)
444510 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
445511 ; CHECK-NEXT: ret i1 [[C]]
449515 ret i1 %c
450516 }
451517
452 define i1 @sadd_icmp_neg_known(i8 %a) {
453 ; CHECK-LABEL: @sadd_icmp_neg_known(
518 define i1 @sadd_icmp_op1_neg_known(i8 %a) {
519 ; CHECK-LABEL: @sadd_icmp_op1_neg_known(
454520 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 -10)
455521 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
456522 ; CHECK-NEXT: ret i1 [[C]]
460526 ret i1 %c
461527 }
462528
463 define i1 @sadd_icmp_neg_unknown(i8 %a) {
464 ; CHECK-LABEL: @sadd_icmp_neg_unknown(
529 define i1 @sadd_icmp_op1_neg_unknown(i8 %a) {
530 ; CHECK-LABEL: @sadd_icmp_op1_neg_unknown(
465531 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 -10)
466532 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
467533 ; CHECK-NEXT: ret i1 [[C]]
570636 %c = icmp ne i8 %b, -128
571637 ret i1 %c
572638 }
639
640 define i1 @ssub_icmp_op1_pos_known(i8 %a) {
641 ; CHECK-LABEL: @ssub_icmp_op1_pos_known(
642 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 10)
643 ; CHECK-NEXT: [[C:%.*]] = icmp sle i8 [[B]], 117
644 ; CHECK-NEXT: ret i1 [[C]]
645 ;
646 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
647 %c = icmp sle i8 %b, 117
648 ret i1 %c
649 }
650
651 define i1 @ssub_icmp_op1_pos_unknown(i8 %a) {
652 ; CHECK-LABEL: @ssub_icmp_op1_pos_unknown(
653 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 10)
654 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
655 ; CHECK-NEXT: ret i1 [[C]]
656 ;
657 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
658 %c = icmp slt i8 %b, 117
659 ret i1 %c
660 }
661
662 define i1 @ssub_icmp_op1_neg_known(i8 %a) {
663 ; CHECK-LABEL: @ssub_icmp_op1_neg_known(
664 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -10)
665 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], -118
666 ; CHECK-NEXT: ret i1 [[C]]
667 ;
668 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
669 %c = icmp sge i8 %b, -118
670 ret i1 %c
671 }
672
673 define i1 @ssub_icmp_op1_neg_unknown(i8 %a) {
674 ; CHECK-LABEL: @ssub_icmp_op1_neg_unknown(
675 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -10)
676 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
677 ; CHECK-NEXT: ret i1 [[C]]
678 ;
679 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
680 %c = icmp sgt i8 %b, -118
681 ret i1 %c
682 }
683
684 define i1 @ssub_icmp_op1_smin(i8 %a) {
685 ; CHECK-LABEL: @ssub_icmp_op1_smin(
686 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -128)
687 ; CHECK-NEXT: [[C:%.*]] = icmp sge i8 [[B]], 0
688 ; CHECK-NEXT: ret i1 [[C]]
689 ;
690 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -128)
691 %c = icmp sge i8 %b, 0
692 ret i1 %c
693 }