PPC: Prepare tests for switch of default denormal-fp-math

These tests fail when the default is switched to assume IEEE denormal
handling. I'm not sure if PPC really has a way to control the denormal
input handling.
This commit is contained in:
Matt Arsenault 2019-11-07 18:26:17 -08:00
parent a4384c756b
commit de71617335
3 changed files with 238 additions and 40 deletions

View File

@ -269,20 +269,23 @@ define float @fmul_fma_fast2(float %x) {
; Reduced precision for sqrt is allowed - should use estimate and NR iterations.
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn:'
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn_ieee:'
; FMFDEBUG: fmul afn {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn:'
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn_ieee:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn_ieee:'
; GLOBALDEBUG: fmul afn {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn:'
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn_ieee:'
define float @sqrt_afn(float %x) {
; FMF-LABEL: sqrt_afn:
define float @sqrt_afn_ieee(float %x) #0 {
; FMF-LABEL: sqrt_afn_ieee:
; FMF: # %bb.0:
; FMF-NEXT: addis 3, 2, .LCPI10_2@toc@ha
; FMF-NEXT: fabs 0, 1
; FMF-NEXT: lfs 2, .LCPI10_2@toc@l(3)
; FMF-NEXT: fcmpu 0, 0, 2
; FMF-NEXT: xxlxor 0, 0, 0
; FMF-NEXT: fcmpu 0, 1, 0
; FMF-NEXT: beq 0, .LBB10_2
; FMF-NEXT: blt 0, .LBB10_2
; FMF-NEXT: # %bb.1:
; FMF-NEXT: xsrsqrtesp 0, 1
; FMF-NEXT: addis 3, 2, .LCPI10_0@toc@ha
@ -298,11 +301,14 @@ define float @sqrt_afn(float %x) {
; FMF-NEXT: fmr 1, 0
; FMF-NEXT: blr
;
; GLOBAL-LABEL: sqrt_afn:
; GLOBAL-LABEL: sqrt_afn_ieee:
; GLOBAL: # %bb.0:
; GLOBAL-NEXT: addis 3, 2, .LCPI10_2@toc@ha
; GLOBAL-NEXT: fabs 0, 1
; GLOBAL-NEXT: lfs 2, .LCPI10_2@toc@l(3)
; GLOBAL-NEXT: fcmpu 0, 0, 2
; GLOBAL-NEXT: xxlxor 0, 0, 0
; GLOBAL-NEXT: fcmpu 0, 1, 0
; GLOBAL-NEXT: beq 0, .LBB10_2
; GLOBAL-NEXT: blt 0, .LBB10_2
; GLOBAL-NEXT: # %bb.1:
; GLOBAL-NEXT: xsrsqrtesp 0, 1
; GLOBAL-NEXT: addis 3, 2, .LCPI10_0@toc@ha
@ -320,18 +326,16 @@ define float @sqrt_afn(float %x) {
ret float %rt
}
; The call is now fully 'fast'. This implies that approximation is allowed.
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn_preserve_sign:'
; FMFDEBUG: fmul afn {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn_preserve_sign:'
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast:'
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn_preserve_sign:'
; GLOBALDEBUG: fmul afn {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn_preserve_sign:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast:'
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast:'
define float @sqrt_fast(float %x) {
; FMF-LABEL: sqrt_fast:
define float @sqrt_afn_preserve_sign(float %x) #1 {
; FMF-LABEL: sqrt_afn_preserve_sign:
; FMF: # %bb.0:
; FMF-NEXT: xxlxor 0, 0, 0
; FMF-NEXT: fcmpu 0, 1, 0
@ -343,14 +347,15 @@ define float @sqrt_fast(float %x) {
; FMF-NEXT: lfs 2, .LCPI11_0@toc@l(3)
; FMF-NEXT: lfs 3, .LCPI11_1@toc@l(4)
; FMF-NEXT: xsmulsp 1, 1, 0
; FMF-NEXT: xsmaddasp 2, 1, 0
; FMF-NEXT: xsmulsp 0, 1, 3
; FMF-NEXT: xsmulsp 0, 0, 2
; FMF-NEXT: xsmulsp 0, 1, 0
; FMF-NEXT: xsmulsp 1, 1, 2
; FMF-NEXT: xsaddsp 0, 0, 3
; FMF-NEXT: xsmulsp 0, 1, 0
; FMF-NEXT: .LBB11_2:
; FMF-NEXT: fmr 1, 0
; FMF-NEXT: blr
;
; GLOBAL-LABEL: sqrt_fast:
; GLOBAL-LABEL: sqrt_afn_preserve_sign:
; GLOBAL: # %bb.0:
; GLOBAL-NEXT: xxlxor 0, 0, 0
; GLOBAL-NEXT: fcmpu 0, 1, 0
@ -367,6 +372,116 @@ define float @sqrt_fast(float %x) {
; GLOBAL-NEXT: xsmulsp 0, 0, 2
; GLOBAL-NEXT: .LBB11_2:
; GLOBAL-NEXT: fmr 1, 0
; GLOBAL-NEXT: blr
%rt = call afn float @llvm.sqrt.f32(float %x)
ret float %rt
}
; The call is now fully 'fast'. This implies that approximation is allowed.
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast_ieee:'
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast_ieee:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast_ieee:'
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast_ieee:'
define float @sqrt_fast_ieee(float %x) #0 {
; FMF-LABEL: sqrt_fast_ieee:
; FMF: # %bb.0:
; FMF-NEXT: addis 3, 2, .LCPI12_2@toc@ha
; FMF-NEXT: fabs 0, 1
; FMF-NEXT: lfs 2, .LCPI12_2@toc@l(3)
; FMF-NEXT: fcmpu 0, 0, 2
; FMF-NEXT: xxlxor 0, 0, 0
; FMF-NEXT: blt 0, .LBB12_2
; FMF-NEXT: # %bb.1:
; FMF-NEXT: xsrsqrtesp 0, 1
; FMF-NEXT: addis 3, 2, .LCPI12_0@toc@ha
; FMF-NEXT: addis 4, 2, .LCPI12_1@toc@ha
; FMF-NEXT: lfs 2, .LCPI12_0@toc@l(3)
; FMF-NEXT: lfs 3, .LCPI12_1@toc@l(4)
; FMF-NEXT: xsmulsp 1, 1, 0
; FMF-NEXT: xsmaddasp 2, 1, 0
; FMF-NEXT: xsmulsp 0, 1, 3
; FMF-NEXT: xsmulsp 0, 0, 2
; FMF-NEXT: .LBB12_2:
; FMF-NEXT: fmr 1, 0
; FMF-NEXT: blr
;
; GLOBAL-LABEL: sqrt_fast_ieee:
; GLOBAL: # %bb.0:
; GLOBAL-NEXT: addis 3, 2, .LCPI12_2@toc@ha
; GLOBAL-NEXT: fabs 0, 1
; GLOBAL-NEXT: lfs 2, .LCPI12_2@toc@l(3)
; GLOBAL-NEXT: fcmpu 0, 0, 2
; GLOBAL-NEXT: xxlxor 0, 0, 0
; GLOBAL-NEXT: blt 0, .LBB12_2
; GLOBAL-NEXT: # %bb.1:
; GLOBAL-NEXT: xsrsqrtesp 0, 1
; GLOBAL-NEXT: addis 3, 2, .LCPI12_0@toc@ha
; GLOBAL-NEXT: addis 4, 2, .LCPI12_1@toc@ha
; GLOBAL-NEXT: lfs 2, .LCPI12_0@toc@l(3)
; GLOBAL-NEXT: lfs 3, .LCPI12_1@toc@l(4)
; GLOBAL-NEXT: xsmulsp 1, 1, 0
; GLOBAL-NEXT: xsmaddasp 2, 1, 0
; GLOBAL-NEXT: xsmulsp 0, 1, 3
; GLOBAL-NEXT: xsmulsp 0, 0, 2
; GLOBAL-NEXT: .LBB12_2:
; GLOBAL-NEXT: fmr 1, 0
; GLOBAL-NEXT: blr
%rt = call fast float @llvm.sqrt.f32(float %x)
ret float %rt
}
; The call is now fully 'fast'. This implies that approximation is allowed.
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast_preserve_sign:'
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast_preserve_sign:'
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast_preserve_sign:'
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast_preserve_sign:'
define float @sqrt_fast_preserve_sign(float %x) #1 {
; FMF-LABEL: sqrt_fast_preserve_sign:
; FMF: # %bb.0:
; FMF-NEXT: xxlxor 0, 0, 0
; FMF-NEXT: fcmpu 0, 1, 0
; FMF-NEXT: beq 0, .LBB13_2
; FMF-NEXT: # %bb.1:
; FMF-NEXT: xsrsqrtesp 0, 1
; FMF-NEXT: addis 3, 2, .LCPI13_0@toc@ha
; FMF-NEXT: addis 4, 2, .LCPI13_1@toc@ha
; FMF-NEXT: lfs 2, .LCPI13_0@toc@l(3)
; FMF-NEXT: lfs 3, .LCPI13_1@toc@l(4)
; FMF-NEXT: xsmulsp 1, 1, 0
; FMF-NEXT: xsmaddasp 2, 1, 0
; FMF-NEXT: xsmulsp 0, 1, 3
; FMF-NEXT: xsmulsp 0, 0, 2
; FMF-NEXT: .LBB13_2:
; FMF-NEXT: fmr 1, 0
; FMF-NEXT: blr
;
; GLOBAL-LABEL: sqrt_fast_preserve_sign:
; GLOBAL: # %bb.0:
; GLOBAL-NEXT: xxlxor 0, 0, 0
; GLOBAL-NEXT: fcmpu 0, 1, 0
; GLOBAL-NEXT: beq 0, .LBB13_2
; GLOBAL-NEXT: # %bb.1:
; GLOBAL-NEXT: xsrsqrtesp 0, 1
; GLOBAL-NEXT: addis 3, 2, .LCPI13_0@toc@ha
; GLOBAL-NEXT: addis 4, 2, .LCPI13_1@toc@ha
; GLOBAL-NEXT: lfs 2, .LCPI13_0@toc@l(3)
; GLOBAL-NEXT: lfs 3, .LCPI13_1@toc@l(4)
; GLOBAL-NEXT: xsmulsp 1, 1, 0
; GLOBAL-NEXT: xsmaddasp 2, 1, 0
; GLOBAL-NEXT: xsmulsp 0, 1, 3
; GLOBAL-NEXT: xsmulsp 0, 0, 2
; GLOBAL-NEXT: .LBB13_2:
; GLOBAL-NEXT: fmr 1, 0
; GLOBAL-NEXT: blr
%rt = call fast float @llvm.sqrt.f32(float %x)
ret float %rt
@ -387,10 +502,10 @@ define double @fcmp_nnan(double %a, double %y, double %z) {
; FMF: # %bb.0:
; FMF-NEXT: xxlxor 0, 0, 0
; FMF-NEXT: xscmpudp 0, 1, 0
; FMF-NEXT: blt 0, .LBB12_2
; FMF-NEXT: blt 0, .LBB14_2
; FMF-NEXT: # %bb.1:
; FMF-NEXT: fmr 3, 2
; FMF-NEXT: .LBB12_2:
; FMF-NEXT: .LBB14_2:
; FMF-NEXT: fmr 1, 3
; FMF-NEXT: blr
;
@ -398,10 +513,10 @@ define double @fcmp_nnan(double %a, double %y, double %z) {
; GLOBAL: # %bb.0:
; GLOBAL-NEXT: xxlxor 0, 0, 0
; GLOBAL-NEXT: xscmpudp 0, 1, 0
; GLOBAL-NEXT: blt 0, .LBB12_2
; GLOBAL-NEXT: blt 0, .LBB14_2
; GLOBAL-NEXT: # %bb.1:
; GLOBAL-NEXT: fmr 3, 2
; GLOBAL-NEXT: .LBB12_2:
; GLOBAL-NEXT: .LBB14_2:
; GLOBAL-NEXT: fmr 1, 3
; GLOBAL-NEXT: blr
%cmp = fcmp nnan ult double %a, 0.0
@ -477,3 +592,5 @@ define float @fneg_fsub_nozeros_1(float %x, float %y, float %z) {
ret float %add
}
attributes #0 = { "denormal-fp-math"="ieee,ieee" }
attributes #1 = { "denormal-fp-math"="preserve-sign,preserve-sign" }

View File

@ -300,8 +300,8 @@ entry:
ret <4 x float> %r
}
define <4 x double> @foo3_fmf(<4 x double> %a) nounwind {
; CHECK-LABEL: foo3_fmf:
define <4 x double> @foo3_fmf_denorm_on(<4 x double> %a) #0 {
; CHECK-LABEL: foo3_fmf_denorm_on:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI12_0@toc@ha
; CHECK-NEXT: qvfrsqrte 0, 1
@ -317,6 +317,36 @@ define <4 x double> @foo3_fmf(<4 x double> %a) nounwind {
; CHECK-NEXT: qvfnmsub 2, 4, 3, 2
; CHECK-NEXT: qvfmul 0, 0, 2
; CHECK-NEXT: qvlfdx 2, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI12_2@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI12_2@toc@l
; CHECK-NEXT: qvlfdx 3, 0, 3
; CHECK-NEXT: qvfmul 0, 0, 1
; CHECK-NEXT: qvfabs 1, 1
; CHECK-NEXT: qvfcmplt 1, 1, 2
; CHECK-NEXT: qvfsel 1, 1, 3, 0
; CHECK-NEXT: blr
entry:
%r = call fast <4 x double> @llvm.sqrt.v4f64(<4 x double> %a)
ret <4 x double> %r
}
define <4 x double> @foo3_fmf_denorm_off(<4 x double> %a) #1 {
; CHECK-LABEL: foo3_fmf_denorm_off:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI13_0@toc@ha
; CHECK-NEXT: qvfrsqrte 0, 1
; CHECK-NEXT: addi 3, 3, .LCPI13_0@toc@l
; CHECK-NEXT: qvlfdx 2, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI13_1@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI13_1@toc@l
; CHECK-NEXT: qvfmul 3, 0, 0
; CHECK-NEXT: qvfmsub 4, 1, 2, 1
; CHECK-NEXT: qvfnmsub 3, 4, 3, 2
; CHECK-NEXT: qvfmul 0, 0, 3
; CHECK-NEXT: qvfmul 3, 0, 0
; CHECK-NEXT: qvfnmsub 2, 4, 3, 2
; CHECK-NEXT: qvfmul 0, 0, 2
; CHECK-NEXT: qvlfdx 2, 0, 3
; CHECK-NEXT: qvfmul 0, 0, 1
; CHECK-NEXT: qvfcmpeq 1, 1, 2
; CHECK-NEXT: qvfsel 1, 1, 2, 0
@ -326,8 +356,8 @@ entry:
ret <4 x double> %r
}
define <4 x double> @foo3_safe(<4 x double> %a) nounwind {
; CHECK-LABEL: foo3_safe:
define <4 x double> @foo3_safe_denorm_on(<4 x double> %a) #0 {
; CHECK-LABEL: foo3_safe_denorm_on:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: qvesplati 2, 1, 3
; CHECK-NEXT: qvesplati 3, 1, 2
@ -347,15 +377,63 @@ entry:
ret <4 x double> %r
}
define <4 x float> @goo3_fmf(<4 x float> %a) nounwind {
; CHECK-LABEL: goo3_fmf:
define <4 x double> @foo3_safe_denorm_off(<4 x double> %a) #1 {
; CHECK-LABEL: foo3_safe_denorm_off:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI14_1@toc@ha
; CHECK-NEXT: qvesplati 2, 1, 3
; CHECK-NEXT: qvesplati 3, 1, 2
; CHECK-NEXT: fsqrt 4, 1
; CHECK-NEXT: qvesplati 1, 1, 1
; CHECK-NEXT: fsqrt 2, 2
; CHECK-NEXT: fsqrt 3, 3
; CHECK-NEXT: fsqrt 1, 1
; CHECK-NEXT: qvgpci 0, 275
; CHECK-NEXT: qvfperm 2, 3, 2, 0
; CHECK-NEXT: qvfperm 0, 4, 1, 0
; CHECK-NEXT: qvgpci 1, 101
; CHECK-NEXT: qvfperm 1, 0, 2, 1
; CHECK-NEXT: blr
entry:
%r = call <4 x double> @llvm.sqrt.v4f64(<4 x double> %a)
ret <4 x double> %r
}
define <4 x float> @goo3_fmf_denorm_on(<4 x float> %a) #0 {
; CHECK-LABEL: goo3_fmf_denorm_on:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI16_1@toc@ha
; CHECK-NEXT: qvfrsqrtes 2, 1
; CHECK-NEXT: addi 3, 3, .LCPI14_1@toc@l
; CHECK-NEXT: addi 3, 3, .LCPI16_1@toc@l
; CHECK-NEXT: qvlfsx 0, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI14_0@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI14_0@toc@l
; CHECK-NEXT: addis 3, 2, .LCPI16_0@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI16_0@toc@l
; CHECK-NEXT: qvfmuls 4, 2, 2
; CHECK-NEXT: qvfnmsubs 3, 1, 0, 1
; CHECK-NEXT: qvfmadds 0, 3, 4, 0
; CHECK-NEXT: qvlfsx 3, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI16_2@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI16_2@toc@l
; CHECK-NEXT: qvlfsx 4, 0, 3
; CHECK-NEXT: qvfmuls 0, 2, 0
; CHECK-NEXT: qvfabs 2, 1
; CHECK-NEXT: qvfmuls 0, 0, 1
; CHECK-NEXT: qvfcmplt 1, 2, 3
; CHECK-NEXT: qvfsel 1, 1, 4, 0
; CHECK-NEXT: blr
entry:
%r = call fast <4 x float> @llvm.sqrt.v4f32(<4 x float> %a)
ret <4 x float> %r
}
define <4 x float> @goo3_fmf_denorm_off(<4 x float> %a) #1 {
; CHECK-LABEL: goo3_fmf_denorm_off:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: addis 3, 2, .LCPI17_1@toc@ha
; CHECK-NEXT: qvfrsqrtes 2, 1
; CHECK-NEXT: addi 3, 3, .LCPI17_1@toc@l
; CHECK-NEXT: qvlfsx 0, 0, 3
; CHECK-NEXT: addis 3, 2, .LCPI17_0@toc@ha
; CHECK-NEXT: addi 3, 3, .LCPI17_0@toc@l
; CHECK-NEXT: qvfmuls 4, 2, 2
; CHECK-NEXT: qvfnmsubs 3, 1, 0, 1
; CHECK-NEXT: qvfmadds 0, 3, 4, 0
@ -391,3 +469,5 @@ entry:
ret <4 x float> %r
}
attributes #0 = { nounwind "denormal-fp-math"="ieee,ieee" }
attributes #1 = { nounwind "denormal-fp-math"="preserve-sign,preserve-sign" }

View File

@ -292,7 +292,7 @@ define float @goo3_safe(float %a) nounwind {
ret float %r
}
define <4 x float> @hoo3_fmf(<4 x float> %a) nounwind {
define <4 x float> @hoo3_fmf(<4 x float> %a) #1 {
; CHECK: @hoo3_fmf
; CHECK: vrsqrtefp
; CHECK-DAG: vcmpeqfp
@ -309,3 +309,4 @@ define <4 x float> @hoo3_safe(<4 x float> %a) nounwind {
}
attributes #0 = { nounwind "reciprocal-estimates"="sqrtf:0,sqrtd:0" }
attributes #1 = { nounwind "denormal-fp-math"="preserve-sign,preserve-sign" }