1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefix=AVX 3 4; If the target's divss/divps instructions are substantially 5; slower than rcpss/rcpps with a Newton-Raphson refinement, 6; we should generate the estimate sequence. 7 8; See PR21385 ( http://llvm.org/bugs/show_bug.cgi?id=21385 ) 9; for details about the accuracy, speed, and implementation 10; differences of x86 reciprocal estimates. 11 12define float @f32_no_estimate(float %x) #0 { 13; AVX-LABEL: f32_no_estimate: 14; AVX: # BB#0: 15; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero 16; AVX-NEXT: vdivss %xmm0, %xmm1, %xmm0 17; AVX-NEXT: retq 18; 19 %div = fdiv fast float 1.0, %x 20 ret float %div 21} 22 23define float @f32_one_step(float %x) #1 { 24; AVX-LABEL: f32_one_step: 25; AVX: # BB#0: 26; AVX-NEXT: vrcpss %xmm0, %xmm0, %xmm1 27; AVX-NEXT: vmulss %xmm1, %xmm0, %xmm0 28; AVX-NEXT: vmovss {{.*#+}} xmm2 = mem[0],zero,zero,zero 29; AVX-NEXT: vsubss %xmm0, %xmm2, %xmm0 30; AVX-NEXT: vmulss %xmm0, %xmm1, %xmm0 31; AVX-NEXT: vaddss %xmm0, %xmm1, %xmm0 32; AVX-NEXT: retq 33; 34 %div = fdiv fast float 1.0, %x 35 ret float %div 36} 37 38define float @f32_two_step(float %x) #2 { 39; AVX-LABEL: f32_two_step: 40; AVX: # BB#0: 41; AVX-NEXT: vrcpss %xmm0, %xmm0, %xmm1 42; AVX-NEXT: vmulss %xmm1, %xmm0, %xmm2 43; AVX-NEXT: vmovss {{.*#+}} xmm3 = mem[0],zero,zero,zero 44; AVX-NEXT: vsubss %xmm2, %xmm3, %xmm2 45; AVX-NEXT: vmulss %xmm2, %xmm1, %xmm2 46; AVX-NEXT: vaddss %xmm2, %xmm1, %xmm1 47; AVX-NEXT: vmulss %xmm1, %xmm0, %xmm0 48; AVX-NEXT: vsubss %xmm0, %xmm3, %xmm0 49; AVX-NEXT: vmulss %xmm0, %xmm1, %xmm0 50; AVX-NEXT: vaddss %xmm0, %xmm1, %xmm0 51; AVX-NEXT: retq 52; 53 %div = fdiv fast float 1.0, %x 54 ret float %div 55} 56 57define <4 x float> @v4f32_no_estimate(<4 x float> %x) #0 { 58; AVX-LABEL: v4f32_no_estimate: 59; AVX: # BB#0: 60; AVX-NEXT: vmovaps {{.*#+}} xmm1 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 61; AVX-NEXT: vdivps %xmm0, %xmm1, %xmm0 62; AVX-NEXT: retq 63; 64 %div = fdiv fast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, %x 65 ret <4 x float> %div 66} 67 68define <4 x float> @v4f32_one_step(<4 x float> %x) #1 { 69; AVX-LABEL: v4f32_one_step: 70; AVX: # BB#0: 71; AVX-NEXT: vrcpps %xmm0, %xmm1 72; AVX-NEXT: vmulps %xmm1, %xmm0, %xmm0 73; AVX-NEXT: vmovaps {{.*#+}} xmm2 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 74; AVX-NEXT: vsubps %xmm0, %xmm2, %xmm0 75; AVX-NEXT: vmulps %xmm0, %xmm1, %xmm0 76; AVX-NEXT: vaddps %xmm0, %xmm1, %xmm0 77; AVX-NEXT: retq 78; 79 %div = fdiv fast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, %x 80 ret <4 x float> %div 81} 82 83define <4 x float> @v4f32_two_step(<4 x float> %x) #2 { 84; AVX-LABEL: v4f32_two_step: 85; AVX: # BB#0: 86; AVX-NEXT: vrcpps %xmm0, %xmm1 87; AVX-NEXT: vmulps %xmm1, %xmm0, %xmm2 88; AVX-NEXT: vmovaps {{.*#+}} xmm3 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 89; AVX-NEXT: vsubps %xmm2, %xmm3, %xmm2 90; AVX-NEXT: vmulps %xmm2, %xmm1, %xmm2 91; AVX-NEXT: vaddps %xmm2, %xmm1, %xmm1 92; AVX-NEXT: vmulps %xmm1, %xmm0, %xmm0 93; AVX-NEXT: vsubps %xmm0, %xmm3, %xmm0 94; AVX-NEXT: vmulps %xmm0, %xmm1, %xmm0 95; AVX-NEXT: vaddps %xmm0, %xmm1, %xmm0 96; AVX-NEXT: retq 97; 98 %div = fdiv fast <4 x float> <float 1.0, float 1.0, float 1.0, float 1.0>, %x 99 ret <4 x float> %div 100} 101 102define <8 x float> @v8f32_no_estimate(<8 x float> %x) #0 { 103; AVX-LABEL: v8f32_no_estimate: 104; AVX: # BB#0: 105; AVX-NEXT: vmovaps {{.*#+}} ymm1 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 106; AVX-NEXT: vdivps %ymm0, %ymm1, %ymm0 107; AVX-NEXT: retq 108; 109 %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>, %x 110 ret <8 x float> %div 111} 112 113define <8 x float> @v8f32_one_step(<8 x float> %x) #1 { 114; AVX-LABEL: v8f32_one_step: 115; AVX: # BB#0: 116; AVX-NEXT: vrcpps %ymm0, %ymm1 117; AVX-NEXT: vmulps %ymm1, %ymm0, %ymm0 118; AVX-NEXT: vmovaps {{.*#+}} ymm2 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 119; AVX-NEXT: vsubps %ymm0, %ymm2, %ymm0 120; AVX-NEXT: vmulps %ymm0, %ymm1, %ymm0 121; AVX-NEXT: vaddps %ymm0, %ymm1, %ymm0 122; AVX-NEXT: retq 123; 124 %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>, %x 125 ret <8 x float> %div 126} 127 128define <8 x float> @v8f32_two_step(<8 x float> %x) #2 { 129; AVX-LABEL: v8f32_two_step: 130; AVX: # BB#0: 131; AVX-NEXT: vrcpps %ymm0, %ymm1 132; AVX-NEXT: vmulps %ymm1, %ymm0, %ymm2 133; AVX-NEXT: vmovaps {{.*#+}} ymm3 = [1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00,1.000000e+00] 134; AVX-NEXT: vsubps %ymm2, %ymm3, %ymm2 135; AVX-NEXT: vmulps %ymm2, %ymm1, %ymm2 136; AVX-NEXT: vaddps %ymm2, %ymm1, %ymm1 137; AVX-NEXT: vmulps %ymm1, %ymm0, %ymm0 138; AVX-NEXT: vsubps %ymm0, %ymm3, %ymm0 139; AVX-NEXT: vmulps %ymm0, %ymm1, %ymm0 140; AVX-NEXT: vaddps %ymm0, %ymm1, %ymm0 141; AVX-NEXT: retq 142; 143 %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>, %x 144 ret <8 x float> %div 145} 146 147attributes #0 = { "unsafe-fp-math"="true" "reciprocal-estimates"="!divf,!vec-divf" } 148attributes #1 = { "unsafe-fp-math"="true" "reciprocal-estimates"="divf,vec-divf" } 149attributes #2 = { "unsafe-fp-math"="true" "reciprocal-estimates"="divf:2,vec-divf:2" } 150 151