Debian Codegraph @

src/x8-lut/gen/x8-lut-wasmsimd-u48.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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/intrinsics-polyfill.h"
15 #include "xnnpack/lut.h"
16 #include "xnnpack/common.h"
17
18
19 void xnn_x8_lut_ukernel__wasmsimd_u48(
20 size_t batch,
21 const uint8_t* input,
22 uint8_t* output,
23 const uint8_t table[restrict XNN_MIN_ELEMENTS(256)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(uint8_t) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const v128_t vtable0 = wasm_v128_load(table);
31 const v128_t vtable1 = wasm_v128_load(table + 16);
32 const v128_t vtable2 = wasm_v128_load(table + 32);
33 const v128_t vtable3 = wasm_v128_load(table + 48);
34 const v128_t vtable4 = wasm_v128_load(table + 64);
35 const v128_t vtable5 = wasm_v128_load(table + 80);
36 const v128_t vtable6 = wasm_v128_load(table + 96);
37 const v128_t vtable7 = wasm_v128_load(table + 112);
38 const v128_t vtable8 = wasm_v128_load(table + 128);
39 const v128_t vtable9 = wasm_v128_load(table + 144);
40 const v128_t vtable10 = wasm_v128_load(table + 160);
41 const v128_t vtable11 = wasm_v128_load(table + 176);
42 const v128_t vtable12 = wasm_v128_load(table + 192);
43 const v128_t vtable13 = wasm_v128_load(table + 208);
44 const v128_t vtable14 = wasm_v128_load(table + 224);
45 const v128_t vtable15 = wasm_v128_load(table + 240);
46 const v128_t voffset = wasm_i8x16_const_splat(16);
47 for (; batch >= 48 * sizeof(uint8_t); batch -= 48 * sizeof(uint8_t)) {
48 v128_t vx0 = wasm_v128_load(input);
49 v128_t vx1 = wasm_v128_load(input + 16);
50 v128_t vx2 = wasm_v128_load(input + 32);
51 input += 48;
52
53 v128_t vy0 = wasm_i8x16_swizzle(vtable0, vx0);
54 v128_t vy1 = wasm_i8x16_swizzle(vtable0, vx1);
55 v128_t vy2 = wasm_i8x16_swizzle(vtable0, vx2);
56
57 vx0 = wasm_i8x16_sub(vx0, voffset);
58 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable1, vx0));
59 vx1 = wasm_i8x16_sub(vx1, voffset);
60 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable1, vx1));
61 vx2 = wasm_i8x16_sub(vx2, voffset);
62 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable1, vx2));
63 vx0 = wasm_i8x16_sub(vx0, voffset);
64 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable2, vx0));
65 vx1 = wasm_i8x16_sub(vx1, voffset);
66 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable2, vx1));
67 vx2 = wasm_i8x16_sub(vx2, voffset);
68 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable2, vx2));
69 vx0 = wasm_i8x16_sub(vx0, voffset);
70 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable3, vx0));
71 vx1 = wasm_i8x16_sub(vx1, voffset);
72 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable3, vx1));
73 vx2 = wasm_i8x16_sub(vx2, voffset);
74 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable3, vx2));
75 vx0 = wasm_i8x16_sub(vx0, voffset);
76 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable4, vx0));
77 vx1 = wasm_i8x16_sub(vx1, voffset);
78 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable4, vx1));
79 vx2 = wasm_i8x16_sub(vx2, voffset);
80 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable4, vx2));
81 vx0 = wasm_i8x16_sub(vx0, voffset);
82 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable5, vx0));
83 vx1 = wasm_i8x16_sub(vx1, voffset);
84 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable5, vx1));
85 vx2 = wasm_i8x16_sub(vx2, voffset);
86 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable5, vx2));
87 vx0 = wasm_i8x16_sub(vx0, voffset);
88 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable6, vx0));
89 vx1 = wasm_i8x16_sub(vx1, voffset);
90 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable6, vx1));
91 vx2 = wasm_i8x16_sub(vx2, voffset);
92 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable6, vx2));
93 vx0 = wasm_i8x16_sub(vx0, voffset);
94 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable7, vx0));
95 vx1 = wasm_i8x16_sub(vx1, voffset);
96 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable7, vx1));
97 vx2 = wasm_i8x16_sub(vx2, voffset);
98 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable7, vx2));
99 vx0 = wasm_i8x16_sub(vx0, voffset);
100 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable8, vx0));
101 vx1 = wasm_i8x16_sub(vx1, voffset);
102 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable8, vx1));
103 vx2 = wasm_i8x16_sub(vx2, voffset);
104 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable8, vx2));
105 vx0 = wasm_i8x16_sub(vx0, voffset);
106 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable9, vx0));
107 vx1 = wasm_i8x16_sub(vx1, voffset);
108 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable9, vx1));
109 vx2 = wasm_i8x16_sub(vx2, voffset);
110 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable9, vx2));
111 vx0 = wasm_i8x16_sub(vx0, voffset);
112 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable10, vx0));
113 vx1 = wasm_i8x16_sub(vx1, voffset);
114 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable10, vx1));
115 vx2 = wasm_i8x16_sub(vx2, voffset);
116 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable10, vx2));
117 vx0 = wasm_i8x16_sub(vx0, voffset);
118 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable11, vx0));
119 vx1 = wasm_i8x16_sub(vx1, voffset);
120 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable11, vx1));
121 vx2 = wasm_i8x16_sub(vx2, voffset);
122 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable11, vx2));
123 vx0 = wasm_i8x16_sub(vx0, voffset);
124 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable12, vx0));
125 vx1 = wasm_i8x16_sub(vx1, voffset);
126 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable12, vx1));
127 vx2 = wasm_i8x16_sub(vx2, voffset);
128 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable12, vx2));
129 vx0 = wasm_i8x16_sub(vx0, voffset);
130 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable13, vx0));
131 vx1 = wasm_i8x16_sub(vx1, voffset);
132 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable13, vx1));
133 vx2 = wasm_i8x16_sub(vx2, voffset);
134 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable13, vx2));
135 vx0 = wasm_i8x16_sub(vx0, voffset);
136 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable14, vx0));
137 vx1 = wasm_i8x16_sub(vx1, voffset);
138 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable14, vx1));
139 vx2 = wasm_i8x16_sub(vx2, voffset);
140 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable14, vx2));
141 vx0 = wasm_i8x16_sub(vx0, voffset);
142 vy0 = wasm_v128_or(vy0, wasm_i8x16_swizzle(vtable15, vx0));
143 vx1 = wasm_i8x16_sub(vx1, voffset);
144 vy1 = wasm_v128_or(vy1, wasm_i8x16_swizzle(vtable15, vx1));
145 vx2 = wasm_i8x16_sub(vx2, voffset);
146 vy2 = wasm_v128_or(vy2, wasm_i8x16_swizzle(vtable15, vx2));
147
148 wasm_v128_store(output, vy0);
149 wasm_v128_store(output + 16, vy1);
150 wasm_v128_store(output + 32, vy2);
151 output += 48;
152 }
153 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
154 v128_t vx = wasm_v128_load(input);
155 input += 16;
156
157 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
158
159 vx = wasm_i8x16_sub(vx, voffset);
160 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
161 vx = wasm_i8x16_sub(vx, voffset);
162 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
163 vx = wasm_i8x16_sub(vx, voffset);
164 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
165 vx = wasm_i8x16_sub(vx, voffset);
166 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
167 vx = wasm_i8x16_sub(vx, voffset);
168 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
169 vx = wasm_i8x16_sub(vx, voffset);
170 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
171 vx = wasm_i8x16_sub(vx, voffset);
172 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
173 vx = wasm_i8x16_sub(vx, voffset);
174 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
175 vx = wasm_i8x16_sub(vx, voffset);
176 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
177 vx = wasm_i8x16_sub(vx, voffset);
178 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
179 vx = wasm_i8x16_sub(vx, voffset);
180 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
181 vx = wasm_i8x16_sub(vx, voffset);
182 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
183 vx = wasm_i8x16_sub(vx, voffset);
184 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
185 vx = wasm_i8x16_sub(vx, voffset);
186 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
187 vx = wasm_i8x16_sub(vx, voffset);
188 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
189
190 wasm_v128_store(output, vy);
191 output += 16;
192 }
193 if XNN_UNLIKELY(batch != 0) {
194 v128_t vx = wasm_v128_load(input);
195
196 v128_t vy = wasm_i8x16_swizzle(vtable0, vx);
197
198 vx = wasm_i8x16_sub(vx, voffset);
199 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable1, vx));
200 vx = wasm_i8x16_sub(vx, voffset);
201 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable2, vx));
202 vx = wasm_i8x16_sub(vx, voffset);
203 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable3, vx));
204 vx = wasm_i8x16_sub(vx, voffset);
205 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable4, vx));
206 vx = wasm_i8x16_sub(vx, voffset);
207 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable5, vx));
208 vx = wasm_i8x16_sub(vx, voffset);
209 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable6, vx));
210 vx = wasm_i8x16_sub(vx, voffset);
211 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable7, vx));
212 vx = wasm_i8x16_sub(vx, voffset);
213 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable8, vx));
214 vx = wasm_i8x16_sub(vx, voffset);
215 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable9, vx));
216 vx = wasm_i8x16_sub(vx, voffset);
217 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable10, vx));
218 vx = wasm_i8x16_sub(vx, voffset);
219 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable11, vx));
220 vx = wasm_i8x16_sub(vx, voffset);
221 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable12, vx));
222 vx = wasm_i8x16_sub(vx, voffset);
223 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable13, vx));
224 vx = wasm_i8x16_sub(vx, voffset);
225 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable14, vx));
226 vx = wasm_i8x16_sub(vx, voffset);
227 vy = wasm_v128_or(vy, wasm_i8x16_swizzle(vtable15, vx));
228
229 if (batch & (8 * sizeof(uint8_t))) {
230 wasm_v128_store64_lane(output, vy, 0);
231 vy = wasm_v64x2_shuffle(vy, vy, 1, 1);
232 output += 8;
233 }
234 if (batch & (4 * sizeof(uint8_t))) {
235 wasm_v128_store32_lane(output, vy, 0);
236 vy = wasm_u64x2_shr(vy, 32);
237 output += 4;
238 }
239 if (batch & (2 * sizeof(uint8_t))) {
240 wasm_v128_store16_lane(output, vy, 0);
241 vy = wasm_u32x4_shr(vy, 16);
242 output += 2;
243 }
244 if (batch & (1 * sizeof(uint8_t))) {
245 wasm_v128_store8_lane(output, vy, 0);
246 }
247 }
248 }