[InstCombine] add tests for fpext+select+fptrunc; NFC

This commit is contained in:
Sanjay Patel 2019-12-05 09:55:56 -05:00
parent c3279beded
commit 403bb33a2e
1 changed files with 84 additions and 0 deletions

View File

@ -48,3 +48,87 @@ define <2 x half> @fmul_constant_op1(<2 x float> %x) {
%r = fptrunc <2 x float> %bo to <2 x half>
ret <2 x half> %r
}
define float @fptrunc_select_true_val(float %x, double %y, i1 %cond) {
; CHECK-LABEL: @fptrunc_select_true_val(
; CHECK-NEXT: [[E:%.*]] = fpext float [[X:%.*]] to double
; CHECK-NEXT: [[SEL:%.*]] = select fast i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
; CHECK-NEXT: ret float [[R]]
;
%e = fpext float %x to double
%sel = select fast i1 %cond, double %y, double %e
%r = fptrunc double %sel to float
ret float %r
}
define <2 x float> @fptrunc_select_false_val(<2 x float> %x, <2 x double> %y, <2 x i1> %cond) {
; CHECK-LABEL: @fptrunc_select_false_val(
; CHECK-NEXT: [[E:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[SEL:%.*]] = select nnan <2 x i1> [[COND:%.*]], <2 x double> [[E]], <2 x double> [[Y:%.*]]
; CHECK-NEXT: [[R:%.*]] = fptrunc <2 x double> [[SEL]] to <2 x float>
; CHECK-NEXT: ret <2 x float> [[R]]
;
%e = fpext <2 x float> %x to <2 x double>
%sel = select nnan <2 x i1> %cond, <2 x double> %e, <2 x double> %y
%r = fptrunc <2 x double> %sel to <2 x float>
ret <2 x float> %r
}
declare void @use(float)
define half @fptrunc_select_true_val_extra_use(half %x, float %y, i1 %cond) {
; CHECK-LABEL: @fptrunc_select_true_val_extra_use(
; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: call void @use(float [[E]])
; CHECK-NEXT: [[SEL:%.*]] = select ninf i1 [[COND:%.*]], float [[Y:%.*]], float [[E]]
; CHECK-NEXT: [[R:%.*]] = fptrunc float [[SEL]] to half
; CHECK-NEXT: ret half [[R]]
;
%e = fpext half %x to float
call void @use(float %e)
%sel = select ninf i1 %cond, float %y, float %e
%r = fptrunc float %sel to half
ret half %r
}
define half @fptrunc_select_true_val_extra_use_2(half %x, float %y, i1 %cond) {
; CHECK-LABEL: @fptrunc_select_true_val_extra_use_2(
; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to float
; CHECK-NEXT: [[SEL:%.*]] = select ninf i1 [[COND:%.*]], float [[Y:%.*]], float [[E]]
; CHECK-NEXT: call void @use(float [[SEL]])
; CHECK-NEXT: [[R:%.*]] = fptrunc float [[SEL]] to half
; CHECK-NEXT: ret half [[R]]
;
%e = fpext half %x to float
%sel = select ninf i1 %cond, float %y, float %e
call void @use(float %sel)
%r = fptrunc float %sel to half
ret half %r
}
define float @fptrunc_select_true_val_type_mismatch(half %x, double %y, i1 %cond) {
; CHECK-LABEL: @fptrunc_select_true_val_type_mismatch(
; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to double
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
; CHECK-NEXT: ret float [[R]]
;
%e = fpext half %x to double
%sel = select i1 %cond, double %y, double %e
%r = fptrunc double %sel to float
ret float %r
}
define float @fptrunc_select_true_val_type_mismatch_fast(half %x, double %y, i1 %cond) {
; CHECK-LABEL: @fptrunc_select_true_val_type_mismatch_fast(
; CHECK-NEXT: [[E:%.*]] = fpext half [[X:%.*]] to double
; CHECK-NEXT: [[SEL:%.*]] = select fast i1 [[COND:%.*]], double [[Y:%.*]], double [[E]]
; CHECK-NEXT: [[R:%.*]] = fptrunc double [[SEL]] to float
; CHECK-NEXT: ret float [[R]]
;
%e = fpext half %x to double
%sel = select fast i1 %cond, double %y, double %e
%r = fptrunc double %sel to float
ret float %r
}