1*4bdc9457SAndroid Build Coastguard Worker // Auto-generated file. Do not edit!
2*4bdc9457SAndroid Build Coastguard Worker // Template: src/f32-vsqrt/neonfma-nr2fma1adj.c.in
3*4bdc9457SAndroid Build Coastguard Worker // Generator: tools/xngen
4*4bdc9457SAndroid Build Coastguard Worker //
5*4bdc9457SAndroid Build Coastguard Worker // Copyright 2020 Google LLC
6*4bdc9457SAndroid Build Coastguard Worker //
7*4bdc9457SAndroid Build Coastguard Worker // This source code is licensed under the BSD-style license found in the
8*4bdc9457SAndroid Build Coastguard Worker // LICENSE file in the root directory of this source tree.
9*4bdc9457SAndroid Build Coastguard Worker
10*4bdc9457SAndroid Build Coastguard Worker #include <assert.h>
11*4bdc9457SAndroid Build Coastguard Worker #include <math.h>
12*4bdc9457SAndroid Build Coastguard Worker
13*4bdc9457SAndroid Build Coastguard Worker #include <arm_neon.h>
14*4bdc9457SAndroid Build Coastguard Worker
15*4bdc9457SAndroid Build Coastguard Worker #include <xnnpack/common.h>
16*4bdc9457SAndroid Build Coastguard Worker #include <xnnpack/vunary.h>
17*4bdc9457SAndroid Build Coastguard Worker
18*4bdc9457SAndroid Build Coastguard Worker
xnn_f32_vsqrt_ukernel__neonfma_nr2fma1adj_x8(size_t n,const float * x,float * y,const union xnn_f32_sqrt_params params[restrict XNN_MIN_ELEMENTS (1)])19*4bdc9457SAndroid Build Coastguard Worker void xnn_f32_vsqrt_ukernel__neonfma_nr2fma1adj_x8(
20*4bdc9457SAndroid Build Coastguard Worker size_t n,
21*4bdc9457SAndroid Build Coastguard Worker const float* x,
22*4bdc9457SAndroid Build Coastguard Worker float* y,
23*4bdc9457SAndroid Build Coastguard Worker const union xnn_f32_sqrt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24*4bdc9457SAndroid Build Coastguard Worker {
25*4bdc9457SAndroid Build Coastguard Worker assert(n != 0);
26*4bdc9457SAndroid Build Coastguard Worker assert(n % sizeof(float) == 0);
27*4bdc9457SAndroid Build Coastguard Worker
28*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vhalf = vmovq_n_f32(0.5f);
29*4bdc9457SAndroid Build Coastguard Worker for (; n >= 8 * sizeof(float); n -= 8 * sizeof(float)) {
30*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vx0123 = vld1q_f32(x); x += 4;
31*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vx4567 = vld1q_f32(x); x += 4;
32*4bdc9457SAndroid Build Coastguard Worker
33*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vrsqrtx0123 = vrsqrteq_f32(vx0123);
34*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vrsqrtx4567 = vrsqrteq_f32(vx4567);
35*4bdc9457SAndroid Build Coastguard Worker
36*4bdc9457SAndroid Build Coastguard Worker float32x4_t vsqrtx0123 = vmulq_f32(vrsqrtx0123, vx0123);
37*4bdc9457SAndroid Build Coastguard Worker float32x4_t vhalfrsqrtx0123 = vmulq_f32(vrsqrtx0123, vhalf);
38*4bdc9457SAndroid Build Coastguard Worker float32x4_t vsqrtx4567 = vmulq_f32(vrsqrtx4567, vx4567);
39*4bdc9457SAndroid Build Coastguard Worker float32x4_t vhalfrsqrtx4567 = vmulq_f32(vrsqrtx4567, vhalf);
40*4bdc9457SAndroid Build Coastguard Worker
41*4bdc9457SAndroid Build Coastguard Worker float32x4_t vresidual0123 = vfmsq_f32(vhalf, vsqrtx0123, vhalfrsqrtx0123);
42*4bdc9457SAndroid Build Coastguard Worker float32x4_t vresidual4567 = vfmsq_f32(vhalf, vsqrtx4567, vhalfrsqrtx4567);
43*4bdc9457SAndroid Build Coastguard Worker
44*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx0123 = vfmaq_f32(vhalfrsqrtx0123, vresidual0123, vhalfrsqrtx0123);
45*4bdc9457SAndroid Build Coastguard Worker vsqrtx0123 = vfmaq_f32(vsqrtx0123, vresidual0123, vsqrtx0123);
46*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx4567 = vfmaq_f32(vhalfrsqrtx4567, vresidual4567, vhalfrsqrtx4567);
47*4bdc9457SAndroid Build Coastguard Worker vsqrtx4567 = vfmaq_f32(vsqrtx4567, vresidual4567, vsqrtx4567);
48*4bdc9457SAndroid Build Coastguard Worker
49*4bdc9457SAndroid Build Coastguard Worker vresidual0123 = vfmsq_f32(vhalf, vsqrtx0123, vhalfrsqrtx0123);
50*4bdc9457SAndroid Build Coastguard Worker vresidual4567 = vfmsq_f32(vhalf, vsqrtx4567, vhalfrsqrtx4567);
51*4bdc9457SAndroid Build Coastguard Worker
52*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx0123 = vfmaq_f32(vhalfrsqrtx0123, vresidual0123, vhalfrsqrtx0123);
53*4bdc9457SAndroid Build Coastguard Worker vsqrtx0123 = vfmaq_f32(vsqrtx0123, vresidual0123, vsqrtx0123);
54*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx4567 = vfmaq_f32(vhalfrsqrtx4567, vresidual4567, vhalfrsqrtx4567);
55*4bdc9457SAndroid Build Coastguard Worker vsqrtx4567 = vfmaq_f32(vsqrtx4567, vresidual4567, vsqrtx4567);
56*4bdc9457SAndroid Build Coastguard Worker
57*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vadjustment0123 = vfmsq_f32(vx0123, vsqrtx0123, vsqrtx0123);
58*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vadjustment4567 = vfmsq_f32(vx4567, vsqrtx4567, vsqrtx4567);
59*4bdc9457SAndroid Build Coastguard Worker
60*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vy0123 = vfmaq_f32(vsqrtx0123, vhalfrsqrtx0123, vadjustment0123);
61*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vy4567 = vfmaq_f32(vsqrtx4567, vhalfrsqrtx4567, vadjustment4567);
62*4bdc9457SAndroid Build Coastguard Worker
63*4bdc9457SAndroid Build Coastguard Worker vst1q_f32(y, vy0123); y += 4;
64*4bdc9457SAndroid Build Coastguard Worker vst1q_f32(y, vy4567); y += 4;
65*4bdc9457SAndroid Build Coastguard Worker }
66*4bdc9457SAndroid Build Coastguard Worker for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) {
67*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vx = vld1q_f32(x); x += 4;
68*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vrsqrtx = vrsqrteq_f32(vx);
69*4bdc9457SAndroid Build Coastguard Worker float32x4_t vsqrtx = vmulq_f32(vrsqrtx, vx);
70*4bdc9457SAndroid Build Coastguard Worker float32x4_t vhalfrsqrtx = vmulq_f32(vrsqrtx, vhalf);
71*4bdc9457SAndroid Build Coastguard Worker float32x4_t vresidual = vfmsq_f32(vhalf, vsqrtx, vhalfrsqrtx);
72*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx = vfmaq_f32(vhalfrsqrtx, vresidual, vhalfrsqrtx);
73*4bdc9457SAndroid Build Coastguard Worker vsqrtx = vfmaq_f32(vsqrtx, vresidual, vsqrtx);
74*4bdc9457SAndroid Build Coastguard Worker vresidual = vfmsq_f32(vhalf, vsqrtx, vhalfrsqrtx);
75*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx = vfmaq_f32(vhalfrsqrtx, vresidual, vhalfrsqrtx);
76*4bdc9457SAndroid Build Coastguard Worker vsqrtx = vfmaq_f32(vsqrtx, vresidual, vsqrtx);
77*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vadjustment = vfmsq_f32(vx, vsqrtx, vsqrtx);
78*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vy = vfmaq_f32(vsqrtx, vhalfrsqrtx, vadjustment);
79*4bdc9457SAndroid Build Coastguard Worker vst1q_f32(y, vy); y += 4;
80*4bdc9457SAndroid Build Coastguard Worker }
81*4bdc9457SAndroid Build Coastguard Worker if XNN_UNLIKELY(n != 0) {
82*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vx = vld1q_f32(x);
83*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vrsqrtx = vrsqrteq_f32(vx);
84*4bdc9457SAndroid Build Coastguard Worker float32x4_t vsqrtx = vmulq_f32(vrsqrtx, vx);
85*4bdc9457SAndroid Build Coastguard Worker float32x4_t vhalfrsqrtx = vmulq_f32(vrsqrtx, vhalf);
86*4bdc9457SAndroid Build Coastguard Worker float32x4_t vresidual = vfmsq_f32(vhalf, vsqrtx, vhalfrsqrtx);
87*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx = vfmaq_f32(vhalfrsqrtx, vresidual, vhalfrsqrtx);
88*4bdc9457SAndroid Build Coastguard Worker vsqrtx = vfmaq_f32(vsqrtx, vresidual, vsqrtx);
89*4bdc9457SAndroid Build Coastguard Worker vresidual = vfmsq_f32(vhalf, vsqrtx, vhalfrsqrtx);
90*4bdc9457SAndroid Build Coastguard Worker vhalfrsqrtx = vfmaq_f32(vhalfrsqrtx, vresidual, vhalfrsqrtx);
91*4bdc9457SAndroid Build Coastguard Worker vsqrtx = vfmaq_f32(vsqrtx, vresidual, vsqrtx);
92*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vadjustment = vfmsq_f32(vx, vsqrtx, vsqrtx);
93*4bdc9457SAndroid Build Coastguard Worker const float32x4_t vy = vfmaq_f32(vsqrtx, vhalfrsqrtx, vadjustment);
94*4bdc9457SAndroid Build Coastguard Worker
95*4bdc9457SAndroid Build Coastguard Worker float32x2_t vy_lo = vget_low_f32(vy);
96*4bdc9457SAndroid Build Coastguard Worker if (n & (2 * sizeof(float))) {
97*4bdc9457SAndroid Build Coastguard Worker vst1_f32(y, vy_lo); y += 2;
98*4bdc9457SAndroid Build Coastguard Worker vy_lo = vget_high_f32(vy);
99*4bdc9457SAndroid Build Coastguard Worker }
100*4bdc9457SAndroid Build Coastguard Worker if (n & (1 * sizeof(float))) {
101*4bdc9457SAndroid Build Coastguard Worker vst1_lane_f32(y, vy_lo, 0);
102*4bdc9457SAndroid Build Coastguard Worker }
103*4bdc9457SAndroid Build Coastguard Worker }
104*4bdc9457SAndroid Build Coastguard Worker }
105