2015-11-24 05:33:58 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2015-06-23 02:29:44 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse2 -recip=!sqrtf,!vec-sqrtf,!divf,!vec-divf | FileCheck %s --check-prefix=NORECIP
|
2015-06-04 09:32:35 +08:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx -recip=sqrtf,vec-sqrtf | FileCheck %s --check-prefix=ESTIMATE
|
2013-05-27 23:44:35 +08:00
|
|
|
|
2015-04-11 02:31:42 +08:00
|
|
|
declare double @__sqrt_finite(double) #0
|
|
|
|
declare float @__sqrtf_finite(float) #0
|
|
|
|
declare x86_fp80 @__sqrtl_finite(x86_fp80) #0
|
|
|
|
declare float @llvm.sqrt.f32(float) #0
|
|
|
|
declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) #0
|
|
|
|
declare <8 x float> @llvm.sqrt.v8f32(<8 x float>) #0
|
2013-05-27 23:44:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
define double @fd(double %d) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: fd:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: sqrtsd %xmm0, %xmm0
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: fd:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: retq
|
|
|
|
%call = tail call double @__sqrt_finite(double %d) #1
|
2013-05-27 23:44:35 +08:00
|
|
|
ret double %call
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define float @ff(float %f) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: ff:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: sqrtss %xmm0, %xmm0
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: ff:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: vrsqrtss %xmm0, %xmm0, %xmm1
|
|
|
|
; ESTIMATE-NEXT: vmulss {{.*}}(%rip), %xmm1, %xmm2
|
2015-07-09 06:35:20 +08:00
|
|
|
; ESTIMATE-NEXT: vmulss %xmm0, %xmm1, %xmm3
|
|
|
|
; ESTIMATE-NEXT: vmulss %xmm3, %xmm1, %xmm1
|
2015-04-11 02:31:42 +08:00
|
|
|
; ESTIMATE-NEXT: vaddss {{.*}}(%rip), %xmm1, %xmm1
|
2015-07-09 06:35:20 +08:00
|
|
|
; ESTIMATE-NEXT: vmulss %xmm0, %xmm2, %xmm2
|
2015-04-11 02:31:42 +08:00
|
|
|
; ESTIMATE-NEXT: vmulss %xmm2, %xmm1, %xmm1
|
|
|
|
; ESTIMATE-NEXT: vxorps %xmm2, %xmm2, %xmm2
|
|
|
|
; ESTIMATE-NEXT: vcmpeqss %xmm2, %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: vandnps %xmm1, %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: retq
|
|
|
|
%call = tail call float @__sqrtf_finite(float %f) #1
|
2013-05-27 23:44:35 +08:00
|
|
|
ret float %call
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
define x86_fp80 @fld(x86_fp80 %ld) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: fld:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: fldt {{[0-9]+}}(%rsp)
|
|
|
|
; NORECIP-NEXT: fsqrt
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: fld:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: fldt {{[0-9]+}}(%rsp)
|
|
|
|
; ESTIMATE-NEXT: fsqrt
|
|
|
|
; ESTIMATE-NEXT: retq
|
|
|
|
%call = tail call x86_fp80 @__sqrtl_finite(x86_fp80 %ld) #1
|
2013-05-27 23:44:35 +08:00
|
|
|
ret x86_fp80 %call
|
|
|
|
}
|
|
|
|
|
2014-10-25 01:59:18 +08:00
|
|
|
|
|
|
|
|
2014-10-25 01:02:16 +08:00
|
|
|
define float @reciprocal_square_root(float %x) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: reciprocal_square_root:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: sqrtss %xmm0, %xmm1
|
|
|
|
; NORECIP-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
|
|
|
|
; NORECIP-NEXT: divss %xmm1, %xmm0
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: reciprocal_square_root:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: vrsqrtss %xmm0, %xmm0, %xmm1
|
|
|
|
; ESTIMATE-NEXT: vmulss {{.*}}(%rip), %xmm1, %xmm2
|
2015-07-09 06:35:20 +08:00
|
|
|
; ESTIMATE-NEXT: vmulss %xmm0, %xmm1, %xmm0
|
2015-04-11 02:31:42 +08:00
|
|
|
; ESTIMATE-NEXT: vmulss %xmm0, %xmm1, %xmm0
|
|
|
|
; ESTIMATE-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: vmulss %xmm2, %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: retq
|
2014-10-25 01:02:16 +08:00
|
|
|
%sqrt = tail call float @llvm.sqrt.f32(float %x)
|
|
|
|
%div = fdiv fast float 1.0, %sqrt
|
|
|
|
ret float %div
|
|
|
|
}
|
|
|
|
|
|
|
|
define <4 x float> @reciprocal_square_root_v4f32(<4 x float> %x) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: reciprocal_square_root_v4f32:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: sqrtps %xmm0, %xmm1
|
|
|
|
; NORECIP-NEXT: movaps {{.*#+}} xmm0 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00]
|
|
|
|
; NORECIP-NEXT: divps %xmm1, %xmm0
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: reciprocal_square_root_v4f32:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: vrsqrtps %xmm0, %xmm1
|
2015-08-12 04:19:23 +08:00
|
|
|
; ESTIMATE-NEXT: vmulps %xmm0, %xmm1, %xmm0
|
|
|
|
; ESTIMATE-NEXT: vmulps %xmm0, %xmm1, %xmm0
|
2015-04-11 02:31:42 +08:00
|
|
|
; ESTIMATE-NEXT: vaddps {{.*}}(%rip), %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: vmulps {{.*}}(%rip), %xmm1, %xmm1
|
|
|
|
; ESTIMATE-NEXT: vmulps %xmm1, %xmm0, %xmm0
|
|
|
|
; ESTIMATE-NEXT: retq
|
2014-10-25 01:02:16 +08:00
|
|
|
%sqrt = tail call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x)
|
|
|
|
%div = fdiv fast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, %sqrt
|
|
|
|
ret <4 x float> %div
|
|
|
|
}
|
|
|
|
|
2014-10-25 01:59:18 +08:00
|
|
|
define <8 x float> @reciprocal_square_root_v8f32(<8 x float> %x) #0 {
|
2015-06-23 02:29:44 +08:00
|
|
|
; NORECIP-LABEL: reciprocal_square_root_v8f32:
|
|
|
|
; NORECIP: # BB#0:
|
|
|
|
; NORECIP-NEXT: sqrtps %xmm1, %xmm2
|
|
|
|
; NORECIP-NEXT: sqrtps %xmm0, %xmm3
|
|
|
|
; NORECIP-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00]
|
|
|
|
; NORECIP-NEXT: movaps %xmm1, %xmm0
|
|
|
|
; NORECIP-NEXT: divps %xmm3, %xmm0
|
|
|
|
; NORECIP-NEXT: divps %xmm2, %xmm1
|
|
|
|
; NORECIP-NEXT: retq
|
2015-04-11 02:31:42 +08:00
|
|
|
;
|
|
|
|
; ESTIMATE-LABEL: reciprocal_square_root_v8f32:
|
|
|
|
; ESTIMATE: # BB#0:
|
|
|
|
; ESTIMATE-NEXT: vrsqrtps %ymm0, %ymm1
|
2015-08-12 08:29:10 +08:00
|
|
|
; ESTIMATE-NEXT: vmulps %ymm0, %ymm1, %ymm0
|
|
|
|
; ESTIMATE-NEXT: vmulps %ymm0, %ymm1, %ymm0
|
2015-04-11 02:31:42 +08:00
|
|
|
; ESTIMATE-NEXT: vaddps {{.*}}(%rip), %ymm0, %ymm0
|
|
|
|
; ESTIMATE-NEXT: vmulps {{.*}}(%rip), %ymm1, %ymm1
|
|
|
|
; ESTIMATE-NEXT: vmulps %ymm1, %ymm0, %ymm0
|
|
|
|
; ESTIMATE-NEXT: retq
|
2014-10-25 01:59:18 +08:00
|
|
|
%sqrt = tail call <8 x float> @llvm.sqrt.v8f32(<8 x float> %x)
|
|
|
|
%div = fdiv fast <8 x float> <float 1.0, float 1.0, float 1.0, float 1.0, float 1.0, float 1.0, float 1.0, float 1.0>, %sqrt
|
|
|
|
ret <8 x float> %div
|
|
|
|
}
|
2014-10-25 01:02:16 +08:00
|
|
|
|
|
|
|
|
2015-04-11 02:31:42 +08:00
|
|
|
attributes #0 = { "unsafe-fp-math"="true" }
|
|
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
|