1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=sse2 -recip=!sqrtf,!vec-sqrtf,!divf,!vec-divf | FileCheck %s --check-prefix=NORECIP 3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx -recip=sqrtf,vec-sqrtf | FileCheck %s --check-prefix=ESTIMATE 4 5declare double @__sqrt_finite(double) #0 6declare float @__sqrtf_finite(float) #0 7declare x86_fp80 @__sqrtl_finite(x86_fp80) #0 8declare float @llvm.sqrt.f32(float) #0 9declare <4 x float> @llvm.sqrt.v4f32(<4 x float>) #0 10declare <8 x float> @llvm.sqrt.v8f32(<8 x float>) #0 11 12 13define double @fd(double %d) #0 { 14; NORECIP-LABEL: fd: 15; NORECIP: # BB#0: 16; NORECIP-NEXT: sqrtsd %xmm0, %xmm0 17; NORECIP-NEXT: retq 18; 19; ESTIMATE-LABEL: fd: 20; ESTIMATE: # BB#0: 21; ESTIMATE-NEXT: vsqrtsd %xmm0, %xmm0, %xmm0 22; ESTIMATE-NEXT: retq 23 %call = tail call double @__sqrt_finite(double %d) #1 24 ret double %call 25} 26 27 28define float @ff(float %f) #0 { 29; NORECIP-LABEL: ff: 30; NORECIP: # BB#0: 31; NORECIP-NEXT: sqrtss %xmm0, %xmm0 32; NORECIP-NEXT: retq 33; 34; ESTIMATE-LABEL: ff: 35; ESTIMATE: # BB#0: 36; ESTIMATE-NEXT: vrsqrtss %xmm0, %xmm0, %xmm1 37; ESTIMATE-NEXT: vmulss %xmm1, %xmm0, %xmm2 38; ESTIMATE-NEXT: vmulss %xmm1, %xmm2, %xmm1 39; ESTIMATE-NEXT: vaddss {{.*}}(%rip), %xmm1, %xmm1 40; ESTIMATE-NEXT: vmulss {{.*}}(%rip), %xmm2, %xmm2 41; ESTIMATE-NEXT: vmulss %xmm1, %xmm2, %xmm1 42; ESTIMATE-NEXT: vxorps %xmm2, %xmm2, %xmm2 43; ESTIMATE-NEXT: vcmpeqss %xmm2, %xmm0, %xmm0 44; ESTIMATE-NEXT: vandnps %xmm1, %xmm0, %xmm0 45; ESTIMATE-NEXT: retq 46 %call = tail call float @__sqrtf_finite(float %f) #1 47 ret float %call 48} 49 50 51define x86_fp80 @fld(x86_fp80 %ld) #0 { 52; NORECIP-LABEL: fld: 53; NORECIP: # BB#0: 54; NORECIP-NEXT: fldt {{[0-9]+}}(%rsp) 55; NORECIP-NEXT: fsqrt 56; NORECIP-NEXT: retq 57; 58; ESTIMATE-LABEL: fld: 59; ESTIMATE: # BB#0: 60; ESTIMATE-NEXT: fldt {{[0-9]+}}(%rsp) 61; ESTIMATE-NEXT: fsqrt 62; ESTIMATE-NEXT: retq 63 %call = tail call x86_fp80 @__sqrtl_finite(x86_fp80 %ld) #1 64 ret x86_fp80 %call 65} 66 67 68 69define float @reciprocal_square_root(float %x) #0 { 70; NORECIP-LABEL: reciprocal_square_root: 71; NORECIP: # BB#0: 72; NORECIP-NEXT: sqrtss %xmm0, %xmm1 73; NORECIP-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 74; NORECIP-NEXT: divss %xmm1, %xmm0 75; NORECIP-NEXT: retq 76; 77; ESTIMATE-LABEL: reciprocal_square_root: 78; ESTIMATE: # BB#0: 79; ESTIMATE-NEXT: vrsqrtss %xmm0, %xmm0, %xmm1 80; ESTIMATE-NEXT: vmulss %xmm1, %xmm1, %xmm2 81; ESTIMATE-NEXT: vmulss %xmm2, %xmm0, %xmm0 82; ESTIMATE-NEXT: vaddss {{.*}}(%rip), %xmm0, %xmm0 83; ESTIMATE-NEXT: vmulss {{.*}}(%rip), %xmm1, %xmm1 84; ESTIMATE-NEXT: vmulss %xmm0, %xmm1, %xmm0 85; ESTIMATE-NEXT: retq 86 %sqrt = tail call float @llvm.sqrt.f32(float %x) 87 %div = fdiv fast float 1.0, %sqrt 88 ret float %div 89} 90 91define <4 x float> @reciprocal_square_root_v4f32(<4 x float> %x) #0 { 92; NORECIP-LABEL: reciprocal_square_root_v4f32: 93; NORECIP: # BB#0: 94; NORECIP-NEXT: sqrtps %xmm0, %xmm1 95; NORECIP-NEXT: movaps {{.*#+}} xmm0 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 96; NORECIP-NEXT: divps %xmm1, %xmm0 97; NORECIP-NEXT: retq 98; 99; ESTIMATE-LABEL: reciprocal_square_root_v4f32: 100; ESTIMATE: # BB#0: 101; ESTIMATE-NEXT: vrsqrtps %xmm0, %xmm1 102; ESTIMATE-NEXT: vmulps %xmm1, %xmm1, %xmm2 103; ESTIMATE-NEXT: vmulps %xmm2, %xmm0, %xmm0 104; ESTIMATE-NEXT: vaddps {{.*}}(%rip), %xmm0, %xmm0 105; ESTIMATE-NEXT: vmulps {{.*}}(%rip), %xmm1, %xmm1 106; ESTIMATE-NEXT: vmulps %xmm0, %xmm1, %xmm0 107; ESTIMATE-NEXT: retq 108 %sqrt = tail call <4 x float> @llvm.sqrt.v4f32(<4 x float> %x) 109 %div = fdiv fast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, %sqrt 110 ret <4 x float> %div 111} 112 113define <8 x float> @reciprocal_square_root_v8f32(<8 x float> %x) #0 { 114; NORECIP-LABEL: reciprocal_square_root_v8f32: 115; NORECIP: # BB#0: 116; NORECIP-NEXT: sqrtps %xmm1, %xmm2 117; NORECIP-NEXT: sqrtps %xmm0, %xmm3 118; NORECIP-NEXT: movaps {{.*#+}} xmm1 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 119; NORECIP-NEXT: movaps %xmm1, %xmm0 120; NORECIP-NEXT: divps %xmm3, %xmm0 121; NORECIP-NEXT: divps %xmm2, %xmm1 122; NORECIP-NEXT: retq 123; 124; ESTIMATE-LABEL: reciprocal_square_root_v8f32: 125; ESTIMATE: # BB#0: 126; ESTIMATE-NEXT: vrsqrtps %ymm0, %ymm1 127; ESTIMATE-NEXT: vmulps %ymm1, %ymm1, %ymm2 128; ESTIMATE-NEXT: vmulps %ymm2, %ymm0, %ymm0 129; ESTIMATE-NEXT: vaddps {{.*}}(%rip), %ymm0, %ymm0 130; ESTIMATE-NEXT: vmulps {{.*}}(%rip), %ymm1, %ymm1 131; ESTIMATE-NEXT: vmulps %ymm0, %ymm1, %ymm0 132; ESTIMATE-NEXT: retq 133 %sqrt = tail call <8 x float> @llvm.sqrt.v8f32(<8 x float> %x) 134 %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 135 ret <8 x float> %div 136} 137 138 139attributes #0 = { "unsafe-fp-math"="true" } 140attributes #1 = { nounwind readnone } 141 142