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