Debian Codegraph @

src/x8-lut/gen/x8-lut-wasmpshufb-u16.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/wasmpshufb.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 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/common.h"
15 #include "xnnpack/lut.h"
16
17
18 void xnn_x8_lut_ukernel__wasmpshufb_u16(
19 size_t batch,
20 const uint8_t* input,
21 uint8_t* output,
22 const uint8_t table[restrict XNN_MIN_ELEMENTS(256)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(uint8_t) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const v128_t vt0 = wasm_v128_load(table);
30 const v128_t vt1 = wasm_v128_load(table + 16);
31 const v128_t vt2 = wasm_v128_load(table + 32);
32 const v128_t vt3 = wasm_v128_load(table + 48);
33 const v128_t vt4 = wasm_v128_load(table + 64);
34 const v128_t vt5 = wasm_v128_load(table + 80);
35 const v128_t vt6 = wasm_v128_load(table + 96);
36 const v128_t vt7 = wasm_v128_load(table + 112);
37 const v128_t vt8 = wasm_v128_load(table + 128);
38 const v128_t vt9 = wasm_v128_load(table + 144);
39 const v128_t vtA = wasm_v128_load(table + 160);
40 const v128_t vtB = wasm_v128_load(table + 176);
41 const v128_t vtC = wasm_v128_load(table + 192);
42 const v128_t vtD = wasm_v128_load(table + 208);
43 const v128_t vtE = wasm_v128_load(table + 224);
44 const v128_t vtF = wasm_v128_load(table + 240);
45
46 const v128_t vtable0 = vt0;
47 const v128_t vtable1 = wasm_v128_xor(vt0, vt1);
48 const v128_t vtable2 = wasm_v128_xor(vt1, vt2);
49 const v128_t vtable3 = wasm_v128_xor(vt2, vt3);
50 const v128_t vtable4 = wasm_v128_xor(vt3, vt4);
51 const v128_t vtable5 = wasm_v128_xor(vt4, vt5);
52 const v128_t vtable6 = wasm_v128_xor(vt5, vt6);
53 const v128_t vtable7 = wasm_v128_xor(vt6, vt7);
54 const v128_t vtable8 = wasm_v128_xor(wasm_v128_xor(vt7, vt8), vtable0);
55 const v128_t vtable9 = wasm_v128_xor(wasm_v128_xor(vt8, vt9), vtable1);
56 const v128_t vtableA = wasm_v128_xor(wasm_v128_xor(vt9, vtA), vtable2);
57 const v128_t vtableB = wasm_v128_xor(wasm_v128_xor(vtA, vtB), vtable3);
58 const v128_t vtableC = wasm_v128_xor(wasm_v128_xor(vtB, vtC), vtable4);
59 const v128_t vtableD = wasm_v128_xor(wasm_v128_xor(vtC, vtD), vtable5);
60 const v128_t vtableE = wasm_v128_xor(wasm_v128_xor(vtD, vtE), vtable6);
61 const v128_t vtableF = wasm_v128_xor(wasm_v128_xor(vtE, vtF), vtable7);
62
63 const v128_t voffset = wasm_i8x16_const_splat(16);
64 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
65 v128_t vx = wasm_v128_load(input);
66 input += 16;
67
68 v128_t vy = wasm_i8x16_relaxed_swizzle(vtable0, vx);
69
70 vx = wasm_i8x16_sub(vx, voffset);
71 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable1, vx));
72 vx = wasm_i8x16_sub(vx, voffset);
73 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable2, vx));
74 vx = wasm_i8x16_sub(vx, voffset);
75 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable3, vx));
76 vx = wasm_i8x16_sub(vx, voffset);
77 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable4, vx));
78 vx = wasm_i8x16_sub(vx, voffset);
79 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable5, vx));
80 vx = wasm_i8x16_sub(vx, voffset);
81 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable6, vx));
82 vx = wasm_i8x16_sub(vx, voffset);
83 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable7, vx));
84 vx = wasm_i8x16_sub(vx, voffset);
85 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable8, vx));
86
87 vx = wasm_i8x16_sub_sat(vx, voffset);
88 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable9, vx));
89 vx = wasm_i8x16_sub_sat(vx, voffset);
90 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableA, vx));
91 vx = wasm_i8x16_sub_sat(vx, voffset);
92 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableB, vx));
93 vx = wasm_i8x16_sub_sat(vx, voffset);
94 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableC, vx));
95 vx = wasm_i8x16_sub_sat(vx, voffset);
96 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableD, vx));
97 vx = wasm_i8x16_sub_sat(vx, voffset);
98 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableE, vx));
99 vx = wasm_i8x16_sub_sat(vx, voffset);
100 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableF, vx));
101
102 wasm_v128_store(output, vy);
103 output += 16;
104 }
105 if XNN_UNLIKELY(batch != 0) {
106 v128_t vx = wasm_v128_load((const v128_t*) input);
107
108 v128_t vy = wasm_i8x16_relaxed_swizzle(vtable0, vx);
109
110 vx = wasm_i8x16_sub(vx, voffset);
111 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable1, vx));
112 vx = wasm_i8x16_sub(vx, voffset);
113 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable2, vx));
114 vx = wasm_i8x16_sub(vx, voffset);
115 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable3, vx));
116 vx = wasm_i8x16_sub(vx, voffset);
117 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable4, vx));
118 vx = wasm_i8x16_sub(vx, voffset);
119 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable5, vx));
120 vx = wasm_i8x16_sub(vx, voffset);
121 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable6, vx));
122 vx = wasm_i8x16_sub(vx, voffset);
123 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable7, vx));
124 vx = wasm_i8x16_sub(vx, voffset);
125 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable8, vx));
126
127 vx = wasm_i8x16_sub_sat(vx, voffset);
128 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable9, vx));
129 vx = wasm_i8x16_sub_sat(vx, voffset);
130 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableA, vx));
131 vx = wasm_i8x16_sub_sat(vx, voffset);
132 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableB, vx));
133 vx = wasm_i8x16_sub_sat(vx, voffset);
134 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableC, vx));
135 vx = wasm_i8x16_sub_sat(vx, voffset);
136 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableD, vx));
137 vx = wasm_i8x16_sub_sat(vx, voffset);
138 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableE, vx));
139 vx = wasm_i8x16_sub_sat(vx, voffset);
140 vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableF, vx));
141
142 if (batch & (8 * sizeof(uint8_t))) {
143 wasm_v128_store64_lane(output, vy, 0);
144 vy = wasm_v64x2_shuffle(vy, vy, 1, 1);
145 output += 8;
146 }
147 if (batch & (4 * sizeof(uint8_t))) {
148 wasm_v128_store32_lane(output, vy, 0);
149 vy = wasm_u64x2_shr(vy, 32);
150 output += 4;
151 }
152 if (batch & (2 * sizeof(uint8_t))) {
153 wasm_v128_store16_lane(output, vy, 0);
154 vy = wasm_u32x4_shr(vy, 16);
155 output += 2;
156 }
157 if (batch & (1 * sizeof(uint8_t))) {
158 wasm_v128_store8_lane(output, vy, 0);
159 }
160 }
161 }