Skip to content

Commit c89def8

Browse files
committed
[InstCombine] Add test for #83225 (NFC)
1 parent 61d4ca8 commit c89def8

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

llvm/test/Transforms/InstCombine/select.ll

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4564,19 +4564,46 @@ define double @sequence_select_with_same_cond_double(double %a, i1 %c1, i1 %c2,
45644564
ret double %s3
45654565
}
45664566

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+
45674594
declare void @use32(i32)
45684595

45694596
define i32 @sequence_select_with_same_cond_extra_use(i1 %c1, i1 %c2){
45704597
; CHECK-LABEL: @sequence_select_with_same_cond_extra_use(
45714598
; CHECK-NEXT: [[S1:%.*]] = select i1 [[C1:%.*]], i32 23, i32 45
4572-
; CHECK-NEXT: call void @use32(i32 [[S1]])
45734599
; CHECK-NEXT: [[S2:%.*]] = select i1 [[C2:%.*]], i32 666, i32 [[S1]]
4600+
; CHECK-NEXT: call void @use32(i32 [[S2]])
45744601
; CHECK-NEXT: [[S3:%.*]] = select i1 [[C1]], i32 789, i32 [[S2]]
45754602
; CHECK-NEXT: ret i32 [[S3]]
45764603
;
45774604
%s1 = select i1 %c1, i32 23, i32 45
4578-
call void @use32(i32 %s1)
45794605
%s2 = select i1 %c2, i32 666, i32 %s1
4606+
call void @use32(i32 %s2)
45804607
%s3 = select i1 %c1, i32 789, i32 %s2
45814608
ret i32 %s3
45824609
}
@@ -4612,3 +4639,18 @@ define i8 @test_replace_freeze_oneuse(i1 %x, i8 %y) {
46124639
%sel = select i1 %x, i8 0, i8 %shl.fr
46134640
ret i8 %sel
46144641
}
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

Comments
 (0)