• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vsqrt/neonfma-nr1rsqrts1fma1adj.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2020 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9 
10 #include <assert.h>
11 #include <math.h>
12 
13 #include <arm_neon.h>
14 
15 #include <xnnpack/common.h>
16 #include <xnnpack/vunary.h>
17 
18 
xnn_f32_vsqrt_ukernel__neonfma_nr1rsqrts1fma1adj_x12(size_t n,const float * x,float * y,const union xnn_f32_sqrt_params params[restrict XNN_MIN_ELEMENTS (1)])19 void xnn_f32_vsqrt_ukernel__neonfma_nr1rsqrts1fma1adj_x12(
20     size_t n,
21     const float* x,
22     float* y,
23     const union xnn_f32_sqrt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
24 {
25   assert(n != 0);
26   assert(n % sizeof(float) == 0);
27 
28   const float32x4_t vhalf = vmovq_n_f32(0.5f);
29   for (; n >= 12 * sizeof(float); n -= 12 * sizeof(float)) {
30     const float32x4_t vx0123 = vld1q_f32(x); x += 4;
31     const float32x4_t vx4567 = vld1q_f32(x); x += 4;
32     const float32x4_t vx89AB = vld1q_f32(x); x += 4;
33 
34     float32x4_t vrsqrtx0123 = vrsqrteq_f32(vx0123);
35     float32x4_t vrsqrtx4567 = vrsqrteq_f32(vx4567);
36     float32x4_t vrsqrtx89AB = vrsqrteq_f32(vx89AB);
37 
38     const float32x4_t vrx0123 = vmulq_f32(vrsqrtx0123, vrsqrtx0123);
39     const float32x4_t vrx4567 = vmulq_f32(vrsqrtx4567, vrsqrtx4567);
40     const float32x4_t vrx89AB = vmulq_f32(vrsqrtx89AB, vrsqrtx89AB);
41 
42     const float32x4_t vcorrection0123 = vrsqrtsq_f32(vx0123, vrx0123);
43     const float32x4_t vcorrection4567 = vrsqrtsq_f32(vx4567, vrx4567);
44     const float32x4_t vcorrection89AB = vrsqrtsq_f32(vx89AB, vrx89AB);
45 
46     vrsqrtx0123 = vmulq_f32(vrsqrtx0123, vcorrection0123);
47     vrsqrtx4567 = vmulq_f32(vrsqrtx4567, vcorrection4567);
48     vrsqrtx89AB = vmulq_f32(vrsqrtx89AB, vcorrection89AB);
49 
50     float32x4_t vsqrtx0123 = vmulq_f32(vrsqrtx0123, vx0123);
51     float32x4_t vhalfrsqrtx0123 = vmulq_f32(vrsqrtx0123, vhalf);
52     float32x4_t vsqrtx4567 = vmulq_f32(vrsqrtx4567, vx4567);
53     float32x4_t vhalfrsqrtx4567 = vmulq_f32(vrsqrtx4567, vhalf);
54     float32x4_t vsqrtx89AB = vmulq_f32(vrsqrtx89AB, vx89AB);
55     float32x4_t vhalfrsqrtx89AB = vmulq_f32(vrsqrtx89AB, vhalf);
56 
57     const float32x4_t vresidual0123 = vfmsq_f32(vhalf, vsqrtx0123, vhalfrsqrtx0123);
58     const float32x4_t vresidual4567 = vfmsq_f32(vhalf, vsqrtx4567, vhalfrsqrtx4567);
59     const float32x4_t vresidual89AB = vfmsq_f32(vhalf, vsqrtx89AB, vhalfrsqrtx89AB);
60 
61     vhalfrsqrtx0123 = vfmaq_f32(vhalfrsqrtx0123, vresidual0123, vhalfrsqrtx0123);
62     vsqrtx0123 = vfmaq_f32(vsqrtx0123, vresidual0123, vsqrtx0123);
63     vhalfrsqrtx4567 = vfmaq_f32(vhalfrsqrtx4567, vresidual4567, vhalfrsqrtx4567);
64     vsqrtx4567 = vfmaq_f32(vsqrtx4567, vresidual4567, vsqrtx4567);
65     vhalfrsqrtx89AB = vfmaq_f32(vhalfrsqrtx89AB, vresidual89AB, vhalfrsqrtx89AB);
66     vsqrtx89AB = vfmaq_f32(vsqrtx89AB, vresidual89AB, vsqrtx89AB);
67 
68     const float32x4_t vadjustment0123 = vfmsq_f32(vx0123, vsqrtx0123, vsqrtx0123);
69     const float32x4_t vadjustment4567 = vfmsq_f32(vx4567, vsqrtx4567, vsqrtx4567);
70     const float32x4_t vadjustment89AB = vfmsq_f32(vx89AB, vsqrtx89AB, vsqrtx89AB);
71 
72     const float32x4_t vy0123 = vfmaq_f32(vsqrtx0123, vhalfrsqrtx0123, vadjustment0123);
73     const float32x4_t vy4567 = vfmaq_f32(vsqrtx4567, vhalfrsqrtx4567, vadjustment4567);
74     const float32x4_t vy89AB = vfmaq_f32(vsqrtx89AB, vhalfrsqrtx89AB, vadjustment89AB);
75 
76     vst1q_f32(y, vy0123); y += 4;
77     vst1q_f32(y, vy4567); y += 4;
78     vst1q_f32(y, vy89AB); y += 4;
79   }
80   if XNN_UNLIKELY(n != 0) {
81     do {
82       const float vx = *x++;
83       const float vy = sqrtf(vx);
84       *y++ = vy;
85       n -= sizeof(float);
86     } while (n != 0);
87   }
88 }
89