@@ -480,6 +480,95 @@ define i1 @test_select_inverse_nonconst4(i64 %x, i64 %y, i64 %z, i1 %cond) {
480
480
ret i1 %sel
481
481
}
482
482
483
+ define i1 @test_select_inverse_samesign_true_arm (i64 %x , i64 %y , i1 %cond ) {
484
+ ; CHECK-LABEL: @test_select_inverse_samesign_true_arm(
485
+ ; CHECK-NEXT: [[CMP1:%.*]] = icmp samesign ult i64 [[X:%.*]], [[Y:%.*]]
486
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp uge i64 [[X]], [[Y]]
487
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMP1]], i1 [[CMP2]]
488
+ ; CHECK-NEXT: ret i1 [[SEL]]
489
+ ;
490
+ %cmp1 = icmp samesign ult i64 %x , %y
491
+ %cmp2 = icmp uge i64 %x , %y
492
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
493
+ ret i1 %sel
494
+ }
495
+
496
+ define i1 @test_select_inverse_samesign_false_arm (i64 %x , i64 %y , i1 %cond ) {
497
+ ; CHECK-LABEL: @test_select_inverse_samesign_false_arm(
498
+ ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[X:%.*]], [[Y:%.*]]
499
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign uge i64 [[X]], [[Y]]
500
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMP1]], i1 [[CMP2]]
501
+ ; CHECK-NEXT: ret i1 [[SEL]]
502
+ ;
503
+ %cmp1 = icmp ult i64 %x , %y
504
+ %cmp2 = icmp samesign uge i64 %x , %y
505
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
506
+ ret i1 %sel
507
+ }
508
+
509
+ define i1 @test_select_inverse_samesign_both (i64 %x , i64 %y , i1 %cond ) {
510
+ ; CHECK-LABEL: @test_select_inverse_samesign_both(
511
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign uge i64 [[X:%.*]], [[Y:%.*]]
512
+ ; CHECK-NEXT: [[SEL:%.*]] = xor i1 [[COND:%.*]], [[CMP2]]
513
+ ; CHECK-NEXT: ret i1 [[SEL]]
514
+ ;
515
+ %cmp1 = icmp samesign ult i64 %x , %y
516
+ %cmp2 = icmp samesign uge i64 %x , %y
517
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
518
+ ret i1 %sel
519
+ }
520
+
521
+ define i1 @test_select_inverse_samesign_false_arm_rhsc_same_sign (i64 %x , i64 %y , i1 %cond ) {
522
+ ; CHECK-LABEL: @test_select_inverse_samesign_false_arm_rhsc_same_sign(
523
+ ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i64 [[X:%.*]], 11
524
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ugt i64 [[X]], 10
525
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMP1]], i1 [[CMP2]]
526
+ ; CHECK-NEXT: ret i1 [[SEL]]
527
+ ;
528
+ %cmp1 = icmp ult i64 %x , 11
529
+ %cmp2 = icmp samesign ugt i64 %x , 10
530
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
531
+ ret i1 %sel
532
+ }
533
+
534
+ define i1 @test_select_inverse_samesign_true_arm_rhsc_same_sign (i64 %x , i64 %y , i1 %cond ) {
535
+ ; CHECK-LABEL: @test_select_inverse_samesign_true_arm_rhsc_same_sign(
536
+ ; CHECK-NEXT: [[CMP1:%.*]] = icmp samesign ult i64 [[X:%.*]], 11
537
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i64 [[X]], 10
538
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMP1]], i1 [[CMP2]]
539
+ ; CHECK-NEXT: ret i1 [[SEL]]
540
+ ;
541
+ %cmp1 = icmp samesign ult i64 %x , 11
542
+ %cmp2 = icmp ugt i64 %x , 10
543
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
544
+ ret i1 %sel
545
+ }
546
+
547
+ define i1 @test_select_inverse_samesign_both_rhsc_same_sign (i64 %x , i64 %y , i1 %cond ) {
548
+ ; CHECK-LABEL: @test_select_inverse_samesign_both_rhsc_same_sign(
549
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign ugt i64 [[X:%.*]], 10
550
+ ; CHECK-NEXT: [[SEL:%.*]] = xor i1 [[COND:%.*]], [[CMP2]]
551
+ ; CHECK-NEXT: ret i1 [[SEL]]
552
+ ;
553
+ %cmp1 = icmp samesign ult i64 %x , 11
554
+ %cmp2 = icmp samesign ugt i64 %x , 10
555
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
556
+ ret i1 %sel
557
+ }
558
+
559
+ define i1 @test_select_inverse_samesign_both_rhsc_diff_sign (i64 %x , i64 %y , i1 %cond ) {
560
+ ; CHECK-LABEL: @test_select_inverse_samesign_both_rhsc_diff_sign(
561
+ ; CHECK-NEXT: [[CMP1:%.*]] = icmp samesign slt i64 [[X:%.*]], 0
562
+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp samesign sgt i64 [[X]], -1
563
+ ; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i1 [[CMP1]], i1 [[CMP2]]
564
+ ; CHECK-NEXT: ret i1 [[SEL]]
565
+ ;
566
+ %cmp1 = icmp samesign slt i64 %x , 0
567
+ %cmp2 = icmp samesign sgt i64 %x , -1
568
+ %sel = select i1 %cond , i1 %cmp1 , i1 %cmp2
569
+ ret i1 %sel
570
+ }
571
+
483
572
define i1 @sel_icmp_two_cmp (i1 %c , i32 %a1 , i32 %a2 , i32 %a3 , i32 %a4 ) {
484
573
; CHECK-LABEL: @sel_icmp_two_cmp(
485
574
; CHECK-NEXT: [[CMP1:%.*]] = icmp ule i32 [[A1:%.*]], [[A2:%.*]]
0 commit comments