; 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
; 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
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:'
-; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
-; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast:'
+; 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:'
-; 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:'
+; 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:'
-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
; 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
; 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
}
; 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
;
; 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
ret float %add
}
+attributes #0 = { "denormal-fp-math"="ieee,ieee" }
+attributes #1 = { "denormal-fp-math"="preserve-sign,preserve-sign" }
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
; 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
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
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: 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, .LCPI16_1@toc@l
+; CHECK-NEXT: qvlfsx 0, 0, 3
+; 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, .LCPI14_1@toc@ha
+; CHECK-NEXT: addis 3, 2, .LCPI17_1@toc@ha
; CHECK-NEXT: qvfrsqrtes 2, 1
-; CHECK-NEXT: addi 3, 3, .LCPI14_1@toc@l
+; CHECK-NEXT: addi 3, 3, .LCPI17_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, .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
ret <4 x float> %r
}
+attributes #0 = { nounwind "denormal-fp-math"="ieee,ieee" }
+attributes #1 = { nounwind "denormal-fp-math"="preserve-sign,preserve-sign" }