• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-velu/wasmsimd-rr2-lut16-p3.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 
12 #include <wasm_simd128.h>
13 
14 #include <xnnpack/vunary.h>
15 #include <xnnpack/common.h>
16 
17 
18 extern XNN_INTERNAL const float xnn_table_exp2minus_k_over_16[16];
19 
xnn_f32_velu_ukernel__wasmsimd_x86_rr2_lut16_p3_x24(size_t n,const float * x,float * y,const union xnn_f32_elu_params params[restrict XNN_MIN_ELEMENTS (1)])20 void xnn_f32_velu_ukernel__wasmsimd_x86_rr2_lut16_p3_x24(
21     size_t n,
22     const float* x,
23     float* y,
24     const union xnn_f32_elu_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
25 {
26   assert(n != 0);
27   assert(n % sizeof(float) == 0);
28   assert(x != NULL);
29   assert(y != NULL);
30 
31   const v128_t vprescale = wasm_v32x4_load_splat(&params->scalar.prescale);
32   const v128_t valpha = wasm_v32x4_load_splat(&params->scalar.alpha);
33   const v128_t vbeta = wasm_v32x4_load_splat(&params->scalar.beta);
34 
35   const v128_t vsat_cutoff = wasm_f32x4_splat(-0x1.154246p+4f);
36   const v128_t vmagic_bias = wasm_f32x4_splat(0x1.800000p19f);
37   const v128_t vlog2e = wasm_f32x4_splat(0x1.715476p+0f);
38   const v128_t vindex_mask = wasm_i32x4_splat(0xF);
39   const v128_t vminus_ln2_hi = wasm_f32x4_splat(-0x1.62E400p-1f);
40   const v128_t vminus_ln2_lo = wasm_f32x4_splat(-0x1.7F7D1Cp-20f);
41   const v128_t vc3 = wasm_f32x4_splat(0x1.55561Cp-3f);
42   const v128_t vc2 = wasm_f32x4_splat(0x1.0001ECp-1f);
43   const v128_t vone = wasm_f32x4_splat(1.0f);
44 
45   for (; n >= 24 * sizeof(float); n -= 24 * sizeof(float)) {
46     v128_t vx0123 = wasm_v128_load(x);
47     v128_t vx4567 = wasm_v128_load(x + 4);
48     v128_t vx89AB = wasm_v128_load(x + 8);
49     v128_t vxCDEF = wasm_v128_load(x + 12);
50     v128_t vxGHIJ = wasm_v128_load(x + 16);
51     v128_t vxKLMN = wasm_v128_load(x + 20);
52     x += 24;
53 
54     const v128_t vz0123 = wasm_f32x4_mul(vx0123, vprescale);
55     const v128_t vz4567 = wasm_f32x4_mul(vx4567, vprescale);
56     const v128_t vz89AB = wasm_f32x4_mul(vx89AB, vprescale);
57     const v128_t vzCDEF = wasm_f32x4_mul(vxCDEF, vprescale);
58     const v128_t vzGHIJ = wasm_f32x4_mul(vxGHIJ, vprescale);
59     const v128_t vzKLMN = wasm_f32x4_mul(vxKLMN, vprescale);
60 
61     v128_t vn0123 = wasm_f32x4_add(wasm_f32x4_mul(vz0123, vlog2e), vmagic_bias);
62     v128_t vn4567 = wasm_f32x4_add(wasm_f32x4_mul(vz4567, vlog2e), vmagic_bias);
63     v128_t vn89AB = wasm_f32x4_add(wasm_f32x4_mul(vz89AB, vlog2e), vmagic_bias);
64     v128_t vnCDEF = wasm_f32x4_add(wasm_f32x4_mul(vzCDEF, vlog2e), vmagic_bias);
65     v128_t vnGHIJ = wasm_f32x4_add(wasm_f32x4_mul(vzGHIJ, vlog2e), vmagic_bias);
66     v128_t vnKLMN = wasm_f32x4_add(wasm_f32x4_mul(vzKLMN, vlog2e), vmagic_bias);
67 
68     const v128_t vidx0123 = wasm_i32x4_shl(wasm_v128_and(vn0123, vindex_mask), 2);
69     const v128_t ven0123 = wasm_i32x4_shl(vn0123, 19);
70     const v128_t vidx4567 = wasm_i32x4_shl(wasm_v128_and(vn4567, vindex_mask), 2);
71     const v128_t ven4567 = wasm_i32x4_shl(vn4567, 19);
72     const v128_t vidx89AB = wasm_i32x4_shl(wasm_v128_and(vn89AB, vindex_mask), 2);
73     const v128_t ven89AB = wasm_i32x4_shl(vn89AB, 19);
74     const v128_t vidxCDEF = wasm_i32x4_shl(wasm_v128_and(vnCDEF, vindex_mask), 2);
75     const v128_t venCDEF = wasm_i32x4_shl(vnCDEF, 19);
76     const v128_t vidxGHIJ = wasm_i32x4_shl(wasm_v128_and(vnGHIJ, vindex_mask), 2);
77     const v128_t venGHIJ = wasm_i32x4_shl(vnGHIJ, 19);
78     const v128_t vidxKLMN = wasm_i32x4_shl(wasm_v128_and(vnKLMN, vindex_mask), 2);
79     const v128_t venKLMN = wasm_i32x4_shl(vnKLMN, 19);
80 
81     const uint64_t vidx01 = wasm_i64x2_extract_lane(vidx0123, 0);
82     const uint64_t vidx23 = wasm_i64x2_extract_lane(vidx0123, 1);
83     const float vl0   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx01));
84     const float vl1 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx01 >> 32)));
85     const float vl2 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx23));
86     const float vl3 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx23 >> 32)));
87     const v128_t vl0123 = wasm_f32x4_make(vl0, vl1, vl2, vl3);
88     const uint64_t vidx45 = wasm_i64x2_extract_lane(vidx4567, 0);
89     const uint64_t vidx67 = wasm_i64x2_extract_lane(vidx4567, 1);
90     const float vl4   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx45));
91     const float vl5 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx45 >> 32)));
92     const float vl6 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx67));
93     const float vl7 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx67 >> 32)));
94     const v128_t vl4567 = wasm_f32x4_make(vl4, vl5, vl6, vl7);
95     const uint64_t vidx89 = wasm_i64x2_extract_lane(vidx89AB, 0);
96     const uint64_t vidxAB = wasm_i64x2_extract_lane(vidx89AB, 1);
97     const float vl8   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx89));
98     const float vl9 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx89 >> 32)));
99     const float vlA = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxAB));
100     const float vlB = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxAB >> 32)));
101     const v128_t vl89AB = wasm_f32x4_make(vl8, vl9, vlA, vlB);
102     const uint64_t vidxCD = wasm_i64x2_extract_lane(vidxCDEF, 0);
103     const uint64_t vidxEF = wasm_i64x2_extract_lane(vidxCDEF, 1);
104     const float vlC   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxCD));
105     const float vlD = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxCD >> 32)));
106     const float vlE = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxEF));
107     const float vlF = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxEF >> 32)));
108     const v128_t vlCDEF = wasm_f32x4_make(vlC, vlD, vlE, vlF);
109     const uint64_t vidxGH = wasm_i64x2_extract_lane(vidxGHIJ, 0);
110     const uint64_t vidxIJ = wasm_i64x2_extract_lane(vidxGHIJ, 1);
111     const float vlG   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxGH));
112     const float vlH = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxGH >> 32)));
113     const float vlI = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxIJ));
114     const float vlJ = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxIJ >> 32)));
115     const v128_t vlGHIJ = wasm_f32x4_make(vlG, vlH, vlI, vlJ);
116     const uint64_t vidxKL = wasm_i64x2_extract_lane(vidxKLMN, 0);
117     const uint64_t vidxMN = wasm_i64x2_extract_lane(vidxKLMN, 1);
118     const float vlK   = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxKL));
119     const float vlL = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxKL >> 32)));
120     const float vlM = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidxMN));
121     const float vlN = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidxMN >> 32)));
122     const v128_t vlKLMN = wasm_f32x4_make(vlK, vlL, vlM, vlN);
123 
124     vn0123 = wasm_f32x4_sub(vn0123, vmagic_bias);
125     v128_t vs0123 = wasm_i32x4_add(vl0123, ven0123);
126     vn4567 = wasm_f32x4_sub(vn4567, vmagic_bias);
127     v128_t vs4567 = wasm_i32x4_add(vl4567, ven4567);
128     vn89AB = wasm_f32x4_sub(vn89AB, vmagic_bias);
129     v128_t vs89AB = wasm_i32x4_add(vl89AB, ven89AB);
130     vnCDEF = wasm_f32x4_sub(vnCDEF, vmagic_bias);
131     v128_t vsCDEF = wasm_i32x4_add(vlCDEF, venCDEF);
132     vnGHIJ = wasm_f32x4_sub(vnGHIJ, vmagic_bias);
133     v128_t vsGHIJ = wasm_i32x4_add(vlGHIJ, venGHIJ);
134     vnKLMN = wasm_f32x4_sub(vnKLMN, vmagic_bias);
135     v128_t vsKLMN = wasm_i32x4_add(vlKLMN, venKLMN);
136 
137     v128_t vt0123 = wasm_f32x4_add(wasm_f32x4_mul(vn0123, vminus_ln2_hi), vz0123);
138     const v128_t vsatm0123 = wasm_f32x4_le(vz0123, vsat_cutoff);
139     v128_t vt4567 = wasm_f32x4_add(wasm_f32x4_mul(vn4567, vminus_ln2_hi), vz4567);
140     const v128_t vsatm4567 = wasm_f32x4_le(vz4567, vsat_cutoff);
141     v128_t vt89AB = wasm_f32x4_add(wasm_f32x4_mul(vn89AB, vminus_ln2_hi), vz89AB);
142     const v128_t vsatm89AB = wasm_f32x4_le(vz89AB, vsat_cutoff);
143     v128_t vtCDEF = wasm_f32x4_add(wasm_f32x4_mul(vnCDEF, vminus_ln2_hi), vzCDEF);
144     const v128_t vsatmCDEF = wasm_f32x4_le(vzCDEF, vsat_cutoff);
145     v128_t vtGHIJ = wasm_f32x4_add(wasm_f32x4_mul(vnGHIJ, vminus_ln2_hi), vzGHIJ);
146     const v128_t vsatmGHIJ = wasm_f32x4_le(vzGHIJ, vsat_cutoff);
147     v128_t vtKLMN = wasm_f32x4_add(wasm_f32x4_mul(vnKLMN, vminus_ln2_hi), vzKLMN);
148     const v128_t vsatmKLMN = wasm_f32x4_le(vzKLMN, vsat_cutoff);
149 
150     vt0123 = wasm_f32x4_add(wasm_f32x4_mul(vn0123, vminus_ln2_lo), vt0123);
151     vs0123 = wasm_v128_andnot(vs0123, vsatm0123);
152     vt4567 = wasm_f32x4_add(wasm_f32x4_mul(vn4567, vminus_ln2_lo), vt4567);
153     vs4567 = wasm_v128_andnot(vs4567, vsatm4567);
154     vt89AB = wasm_f32x4_add(wasm_f32x4_mul(vn89AB, vminus_ln2_lo), vt89AB);
155     vs89AB = wasm_v128_andnot(vs89AB, vsatm89AB);
156     vtCDEF = wasm_f32x4_add(wasm_f32x4_mul(vnCDEF, vminus_ln2_lo), vtCDEF);
157     vsCDEF = wasm_v128_andnot(vsCDEF, vsatmCDEF);
158     vtGHIJ = wasm_f32x4_add(wasm_f32x4_mul(vnGHIJ, vminus_ln2_lo), vtGHIJ);
159     vsGHIJ = wasm_v128_andnot(vsGHIJ, vsatmGHIJ);
160     vtKLMN = wasm_f32x4_add(wasm_f32x4_mul(vnKLMN, vminus_ln2_lo), vtKLMN);
161     vsKLMN = wasm_v128_andnot(vsKLMN, vsatmKLMN);
162 
163     vt0123 = wasm_v128_andnot(vt0123, vsatm0123);
164     v128_t vp0123 = wasm_f32x4_add(wasm_f32x4_mul(vc3, vt0123), vc2);
165     vt4567 = wasm_v128_andnot(vt4567, vsatm4567);
166     v128_t vp4567 = wasm_f32x4_add(wasm_f32x4_mul(vc3, vt4567), vc2);
167     vt89AB = wasm_v128_andnot(vt89AB, vsatm89AB);
168     v128_t vp89AB = wasm_f32x4_add(wasm_f32x4_mul(vc3, vt89AB), vc2);
169     vtCDEF = wasm_v128_andnot(vtCDEF, vsatmCDEF);
170     v128_t vpCDEF = wasm_f32x4_add(wasm_f32x4_mul(vc3, vtCDEF), vc2);
171     vtGHIJ = wasm_v128_andnot(vtGHIJ, vsatmGHIJ);
172     v128_t vpGHIJ = wasm_f32x4_add(wasm_f32x4_mul(vc3, vtGHIJ), vc2);
173     vtKLMN = wasm_v128_andnot(vtKLMN, vsatmKLMN);
174     v128_t vpKLMN = wasm_f32x4_add(wasm_f32x4_mul(vc3, vtKLMN), vc2);
175 
176     vp0123 = wasm_f32x4_mul(vp0123, vt0123);
177     vp4567 = wasm_f32x4_mul(vp4567, vt4567);
178     vp89AB = wasm_f32x4_mul(vp89AB, vt89AB);
179     vpCDEF = wasm_f32x4_mul(vpCDEF, vtCDEF);
180     vpGHIJ = wasm_f32x4_mul(vpGHIJ, vtGHIJ);
181     vpKLMN = wasm_f32x4_mul(vpKLMN, vtKLMN);
182 
183     vt0123 = wasm_f32x4_mul(vt0123, vs0123);
184     vs0123 = wasm_f32x4_sub(vs0123, vone);
185     vt4567 = wasm_f32x4_mul(vt4567, vs4567);
186     vs4567 = wasm_f32x4_sub(vs4567, vone);
187     vt89AB = wasm_f32x4_mul(vt89AB, vs89AB);
188     vs89AB = wasm_f32x4_sub(vs89AB, vone);
189     vtCDEF = wasm_f32x4_mul(vtCDEF, vsCDEF);
190     vsCDEF = wasm_f32x4_sub(vsCDEF, vone);
191     vtGHIJ = wasm_f32x4_mul(vtGHIJ, vsGHIJ);
192     vsGHIJ = wasm_f32x4_sub(vsGHIJ, vone);
193     vtKLMN = wasm_f32x4_mul(vtKLMN, vsKLMN);
194     vsKLMN = wasm_f32x4_sub(vsKLMN, vone);
195 
196     vp0123 = wasm_f32x4_add(wasm_f32x4_mul(vp0123, vt0123), vt0123);
197     vp4567 = wasm_f32x4_add(wasm_f32x4_mul(vp4567, vt4567), vt4567);
198     vp89AB = wasm_f32x4_add(wasm_f32x4_mul(vp89AB, vt89AB), vt89AB);
199     vpCDEF = wasm_f32x4_add(wasm_f32x4_mul(vpCDEF, vtCDEF), vtCDEF);
200     vpGHIJ = wasm_f32x4_add(wasm_f32x4_mul(vpGHIJ, vtGHIJ), vtGHIJ);
201     vpKLMN = wasm_f32x4_add(wasm_f32x4_mul(vpKLMN, vtKLMN), vtKLMN);
202 
203     const v128_t ve0123 = wasm_f32x4_mul(wasm_f32x4_add(vp0123, vs0123), valpha);
204     const v128_t ve4567 = wasm_f32x4_mul(wasm_f32x4_add(vp4567, vs4567), valpha);
205     const v128_t ve89AB = wasm_f32x4_mul(wasm_f32x4_add(vp89AB, vs89AB), valpha);
206     const v128_t veCDEF = wasm_f32x4_mul(wasm_f32x4_add(vpCDEF, vsCDEF), valpha);
207     const v128_t veGHIJ = wasm_f32x4_mul(wasm_f32x4_add(vpGHIJ, vsGHIJ), valpha);
208     const v128_t veKLMN = wasm_f32x4_mul(wasm_f32x4_add(vpKLMN, vsKLMN), valpha);
209 
210     const v128_t vsignm0123 = wasm_i32x4_shr(vx0123, 31);
211     vx0123 = wasm_f32x4_mul(vx0123, vbeta);
212     const v128_t vsignm4567 = wasm_i32x4_shr(vx4567, 31);
213     vx4567 = wasm_f32x4_mul(vx4567, vbeta);
214     const v128_t vsignm89AB = wasm_i32x4_shr(vx89AB, 31);
215     vx89AB = wasm_f32x4_mul(vx89AB, vbeta);
216     const v128_t vsignmCDEF = wasm_i32x4_shr(vxCDEF, 31);
217     vxCDEF = wasm_f32x4_mul(vxCDEF, vbeta);
218     const v128_t vsignmGHIJ = wasm_i32x4_shr(vxGHIJ, 31);
219     vxGHIJ = wasm_f32x4_mul(vxGHIJ, vbeta);
220     const v128_t vsignmKLMN = wasm_i32x4_shr(vxKLMN, 31);
221     vxKLMN = wasm_f32x4_mul(vxKLMN, vbeta);
222 
223     const v128_t vy0123 = wasm_v128_bitselect(ve0123, vx0123, vsignm0123);
224     const v128_t vy4567 = wasm_v128_bitselect(ve4567, vx4567, vsignm4567);
225     const v128_t vy89AB = wasm_v128_bitselect(ve89AB, vx89AB, vsignm89AB);
226     const v128_t vyCDEF = wasm_v128_bitselect(veCDEF, vxCDEF, vsignmCDEF);
227     const v128_t vyGHIJ = wasm_v128_bitselect(veGHIJ, vxGHIJ, vsignmGHIJ);
228     const v128_t vyKLMN = wasm_v128_bitselect(veKLMN, vxKLMN, vsignmKLMN);
229 
230     wasm_v128_store(y, vy0123);
231     wasm_v128_store(y + 4, vy4567);
232     wasm_v128_store(y + 8, vy89AB);
233     wasm_v128_store(y + 12, vyCDEF);
234     wasm_v128_store(y + 16, vyGHIJ);
235     wasm_v128_store(y + 20, vyKLMN);
236     y += 24;
237   }
238   for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) {
239     v128_t vx = wasm_v128_load(x);
240     x += 4;
241 
242     const v128_t vz = wasm_f32x4_mul(vx, vprescale);
243 
244     v128_t vn = wasm_f32x4_add(wasm_f32x4_mul(vz, vlog2e), vmagic_bias);
245     const v128_t vidx = wasm_i32x4_shl(wasm_v128_and(vn, vindex_mask), 2);
246     const v128_t ven = wasm_i32x4_shl(vn, 19);
247 
248     const uint64_t vidx_lo = wasm_i64x2_extract_lane(vidx, 0);
249     const uint64_t vidx_hi = wasm_i64x2_extract_lane(vidx, 1);
250     const float vl0 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx_lo));
251     const float vl1 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx_lo >> 32)));
252     const float vl2 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx_hi));
253     const float vl3 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx_hi >> 32)));
254     const v128_t vl = wasm_f32x4_make(vl0, vl1, vl2, vl3);
255 
256     v128_t vs = wasm_i32x4_add(vl, ven);
257     vn = wasm_f32x4_sub(vn, vmagic_bias);
258 
259     v128_t vt = wasm_f32x4_add(wasm_f32x4_mul(vn, vminus_ln2_hi), vz);
260     const v128_t vsatm = wasm_f32x4_le(vz, vsat_cutoff);
261     vt = wasm_f32x4_add(wasm_f32x4_mul(vn, vminus_ln2_lo), vt);
262     vs = wasm_v128_andnot(vs, vsatm);
263     vt = wasm_v128_andnot(vt, vsatm);
264 
265     v128_t vp = wasm_f32x4_add(wasm_f32x4_mul(vc3, vt), vc2);
266     vp = wasm_f32x4_mul(vp, vt);
267 
268     vt = wasm_f32x4_mul(vt, vs);
269     vs = wasm_f32x4_sub(vs, vone);
270     vp = wasm_f32x4_add(wasm_f32x4_mul(vp, vt), vt);
271     const v128_t ve = wasm_f32x4_mul(wasm_f32x4_add(vp, vs), valpha);
272 
273     const v128_t vsignm = wasm_i32x4_shr(vx, 31);
274     vx = wasm_f32x4_mul(vx, vbeta);
275     const v128_t vy = wasm_v128_bitselect(ve, vx, vsignm);
276 
277     wasm_v128_store(y, vy);
278     y += 4;
279   }
280   if XNN_UNLIKELY(n != 0) {
281     v128_t vx = wasm_v128_load(x);
282 
283     const v128_t vz = wasm_f32x4_mul(vx, vprescale);
284 
285     v128_t vn = wasm_f32x4_add(wasm_f32x4_mul(vz, vlog2e), vmagic_bias);
286     const v128_t vidx = wasm_i32x4_shl(wasm_v128_and(vn, vindex_mask), 2);
287     const v128_t ven = wasm_i32x4_shl(vn, 19);
288 
289     const uint64_t vidx_lo = wasm_i64x2_extract_lane(vidx, 0);
290     const uint64_t vidx_hi = wasm_i64x2_extract_lane(vidx, 1);
291     const float vl0 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx_lo));
292     const float vl1 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx_lo >> 32)));
293     const float vl2 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) vidx_hi));
294     const float vl3 = *((const float*) ((uintptr_t) xnn_table_exp2minus_k_over_16 + (uint32_t) (vidx_hi >> 32)));
295     const v128_t vl = wasm_f32x4_make(vl0, vl1, vl2, vl3);
296 
297     v128_t vs = wasm_i32x4_add(vl, ven);
298     vn = wasm_f32x4_sub(vn, vmagic_bias);
299 
300     v128_t vt = wasm_f32x4_add(wasm_f32x4_mul(vn, vminus_ln2_hi), vz);
301     const v128_t vsatm = wasm_f32x4_le(vz, vsat_cutoff);
302     vt = wasm_f32x4_add(wasm_f32x4_mul(vn, vminus_ln2_lo), vt);
303     vs = wasm_v128_andnot(vs, vsatm);
304     vt = wasm_v128_andnot(vt, vsatm);
305 
306     v128_t vp = wasm_f32x4_add(wasm_f32x4_mul(vc3, vt), vc2);
307     vp = wasm_f32x4_mul(vp, vt);
308 
309     vt = wasm_f32x4_mul(vt, vs);
310     vs = wasm_f32x4_sub(vs, vone);
311     vp = wasm_f32x4_add(wasm_f32x4_mul(vp, vt), vt);
312     const v128_t ve = wasm_f32x4_mul(wasm_f32x4_add(vp, vs), valpha);
313 
314     const v128_t vsignm = wasm_i32x4_shr(vx, 31);
315     vx = wasm_f32x4_mul(vx, vbeta);
316     v128_t vy = wasm_v128_bitselect(ve, vx, vsignm);
317 
318     if (n & (2 * sizeof(float))) {
319       *((double*) y) = wasm_f64x2_extract_lane(vy, 0);
320       vy = wasm_v32x4_shuffle(vy, vy, 2, 3, 2, 3);
321       y += 2;
322     }
323     if (n & (1 * sizeof(float))) {
324       *y = wasm_f32x4_extract_lane(vy, 0);
325     }
326   }
327 }
328