@@ -4564,19 +4564,46 @@ define double @sequence_select_with_same_cond_double(double %a, i1 %c1, i1 %c2,
4564
4564
ret double %s3
4565
4565
}
4566
4566
4567
+ ; Confirm the FMF flag is propagated
4568
+ define float @sequence_select_with_same_cond_float_and_fmf_flag1 (i1 %c1 , i1 %c2 ){
4569
+ ; CHECK-LABEL: @sequence_select_with_same_cond_float_and_fmf_flag1(
4570
+ ; CHECK-NEXT: [[S1:%.*]] = select i1 [[C1:%.*]], float 2.300000e+01, float 4.500000e+01
4571
+ ; CHECK-NEXT: [[S2:%.*]] = select fast i1 [[C2:%.*]], float 6.660000e+02, float [[S1]]
4572
+ ; CHECK-NEXT: [[S3:%.*]] = select fast i1 [[C1]], float 7.890000e+02, float [[S2]]
4573
+ ; CHECK-NEXT: ret float [[S3]]
4574
+ ;
4575
+ %s1 = select i1 %c1 , float 23 .0 , float 45 .0
4576
+ %s2 = select fast i1 %c2 , float 666 .0 , float %s1 ; has fast flag
4577
+ %s3 = select fast i1 %c1 , float 789 .0 , float %s2
4578
+ ret float %s3
4579
+ }
4580
+
4581
+ define float @sequence_select_with_same_cond_float_and_fmf_flag2 (i1 %c1 , i1 %c2 ){
4582
+ ; CHECK-LABEL: @sequence_select_with_same_cond_float_and_fmf_flag2(
4583
+ ; CHECK-NEXT: [[S1:%.*]] = select fast i1 [[C1:%.*]], float 2.300000e+01, float 4.500000e+01
4584
+ ; CHECK-NEXT: [[S2:%.*]] = select i1 [[C2:%.*]], float 6.660000e+02, float [[S1]]
4585
+ ; CHECK-NEXT: [[S3:%.*]] = select fast i1 [[C1]], float 7.890000e+02, float [[S2]]
4586
+ ; CHECK-NEXT: ret float [[S3]]
4587
+ ;
4588
+ %s1 = select fast i1 %c1 , float 23 .0 , float 45 .0
4589
+ %s2 = select i1 %c2 , float 666 .0 , float %s1 ; has no fast flag
4590
+ %s3 = select fast i1 %c1 , float 789 .0 , float %s2
4591
+ ret float %s3
4592
+ }
4593
+
4567
4594
declare void @use32 (i32 )
4568
4595
4569
4596
define i32 @sequence_select_with_same_cond_extra_use (i1 %c1 , i1 %c2 ){
4570
4597
; CHECK-LABEL: @sequence_select_with_same_cond_extra_use(
4571
4598
; CHECK-NEXT: [[S1:%.*]] = select i1 [[C1:%.*]], i32 23, i32 45
4572
- ; CHECK-NEXT: call void @use32(i32 [[S1]])
4573
4599
; CHECK-NEXT: [[S2:%.*]] = select i1 [[C2:%.*]], i32 666, i32 [[S1]]
4600
+ ; CHECK-NEXT: call void @use32(i32 [[S2]])
4574
4601
; CHECK-NEXT: [[S3:%.*]] = select i1 [[C1]], i32 789, i32 [[S2]]
4575
4602
; CHECK-NEXT: ret i32 [[S3]]
4576
4603
;
4577
4604
%s1 = select i1 %c1 , i32 23 , i32 45
4578
- call void @use32 (i32 %s1 )
4579
4605
%s2 = select i1 %c2 , i32 666 , i32 %s1
4606
+ call void @use32 (i32 %s2 )
4580
4607
%s3 = select i1 %c1 , i32 789 , i32 %s2
4581
4608
ret i32 %s3
4582
4609
}
@@ -4612,3 +4639,18 @@ define i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {
4612
4639
%sel = select i1 %x , i8 0 , i8 %shl.fr
4613
4640
ret i8 %sel
4614
4641
}
4642
+
4643
+ define i8 @sequence_select_with_same_cond_multi_arms (i1 %cond0 , i1 %cond1 , i8 %a , i8 %b ) {
4644
+ ; CHECK-LABEL: @sequence_select_with_same_cond_multi_arms(
4645
+ ; CHECK-NEXT: [[SEL0:%.*]] = select i1 [[COND0:%.*]], i8 [[A:%.*]], i8 [[B:%.*]]
4646
+ ; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[COND1:%.*]], i8 [[SEL0]], i8 2
4647
+ ; CHECK-NEXT: [[SEL2:%.*]] = select i1 [[COND1]], i8 [[SEL0]], i8 3
4648
+ ; CHECK-NEXT: [[SEL3:%.*]] = select i1 [[COND0]], i8 [[SEL1]], i8 [[SEL2]]
4649
+ ; CHECK-NEXT: ret i8 [[SEL3]]
4650
+ ;
4651
+ %sel0 = select i1 %cond0 , i8 %a , i8 %b
4652
+ %sel1 = select i1 %cond1 , i8 %sel0 , i8 2 ; %sel1 used in multi arms
4653
+ %sel2 = select i1 %cond1 , i8 %sel1 , i8 3
4654
+ %sel3 = select i1 %cond0 , i8 %sel1 , i8 %sel2
4655
+ ret i8 %sel3
4656
+ }
0 commit comments