| 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_u48( |
| 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 >= 48 * sizeof(uint8_t); batch -= 48 * sizeof(uint8_t)) { |
| 65 |
v128_t vx0 = wasm_v128_load((const v128_t*) input); |
| 66 |
v128_t vx1 = wasm_v128_load((const v128_t*) (input + 16)); |
| 67 |
v128_t vx2 = wasm_v128_load((const v128_t*) (input + 32)); |
| 68 |
input += 48; |
| 69 |
|
| 70 |
v128_t vy0 = wasm_i8x16_relaxed_swizzle(vtable0, vx0); |
| 71 |
v128_t vy1 = wasm_i8x16_relaxed_swizzle(vtable0, vx1); |
| 72 |
v128_t vy2 = wasm_i8x16_relaxed_swizzle(vtable0, vx2); |
| 73 |
|
| 74 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 75 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 76 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 77 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable1, vx0)); |
| 78 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable1, vx1)); |
| 79 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable1, vx2)); |
| 80 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 81 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 82 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 83 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable2, vx0)); |
| 84 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable2, vx1)); |
| 85 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable2, vx2)); |
| 86 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 87 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 88 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 89 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable3, vx0)); |
| 90 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable3, vx1)); |
| 91 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable3, vx2)); |
| 92 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 93 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 94 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 95 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable4, vx0)); |
| 96 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable4, vx1)); |
| 97 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable4, vx2)); |
| 98 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 99 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 100 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 101 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable5, vx0)); |
| 102 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable5, vx1)); |
| 103 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable5, vx2)); |
| 104 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 105 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 106 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 107 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable6, vx0)); |
| 108 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable6, vx1)); |
| 109 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable6, vx2)); |
| 110 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 111 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 112 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 113 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable7, vx0)); |
| 114 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable7, vx1)); |
| 115 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable7, vx2)); |
| 116 |
vx0 = wasm_i8x16_sub(vx0, voffset); |
| 117 |
vx1 = wasm_i8x16_sub(vx1, voffset); |
| 118 |
vx2 = wasm_i8x16_sub(vx2, voffset); |
| 119 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable8, vx0)); |
| 120 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable8, vx1)); |
| 121 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable8, vx2)); |
| 122 |
|
| 123 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 124 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 125 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 126 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtable9, vx0)); |
| 127 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtable9, vx1)); |
| 128 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtable9, vx2)); |
| 129 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 130 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 131 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 132 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableA, vx0)); |
| 133 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableA, vx1)); |
| 134 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableA, vx2)); |
| 135 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 136 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 137 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 138 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableB, vx0)); |
| 139 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableB, vx1)); |
| 140 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableB, vx2)); |
| 141 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 142 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 143 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 144 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableC, vx0)); |
| 145 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableC, vx1)); |
| 146 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableC, vx2)); |
| 147 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 148 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 149 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 150 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableD, vx0)); |
| 151 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableD, vx1)); |
| 152 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableD, vx2)); |
| 153 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 154 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 155 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 156 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableE, vx0)); |
| 157 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableE, vx1)); |
| 158 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableE, vx2)); |
| 159 |
vx0 = wasm_i8x16_sub_sat(vx0, voffset); |
| 160 |
vx1 = wasm_i8x16_sub_sat(vx1, voffset); |
| 161 |
vx2 = wasm_i8x16_sub_sat(vx2, voffset); |
| 162 |
vy0 = wasm_v128_xor(vy0, wasm_i8x16_relaxed_swizzle(vtableF, vx0)); |
| 163 |
vy1 = wasm_v128_xor(vy1, wasm_i8x16_relaxed_swizzle(vtableF, vx1)); |
| 164 |
vy2 = wasm_v128_xor(vy2, wasm_i8x16_relaxed_swizzle(vtableF, vx2)); |
| 165 |
|
| 166 |
wasm_v128_store(output, vy0); |
| 167 |
wasm_v128_store(output + 16, vy1); |
| 168 |
wasm_v128_store(output + 32, vy2); |
| 169 |
output += 48; |
| 170 |
} |
| 171 |
for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) { |
| 172 |
v128_t vx = wasm_v128_load(input); |
| 173 |
input += 16; |
| 174 |
|
| 175 |
v128_t vy = wasm_i8x16_relaxed_swizzle(vtable0, vx); |
| 176 |
|
| 177 |
vx = wasm_i8x16_sub(vx, voffset); |
| 178 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable1, vx)); |
| 179 |
vx = wasm_i8x16_sub(vx, voffset); |
| 180 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable2, vx)); |
| 181 |
vx = wasm_i8x16_sub(vx, voffset); |
| 182 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable3, vx)); |
| 183 |
vx = wasm_i8x16_sub(vx, voffset); |
| 184 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable4, vx)); |
| 185 |
vx = wasm_i8x16_sub(vx, voffset); |
| 186 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable5, vx)); |
| 187 |
vx = wasm_i8x16_sub(vx, voffset); |
| 188 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable6, vx)); |
| 189 |
vx = wasm_i8x16_sub(vx, voffset); |
| 190 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable7, vx)); |
| 191 |
vx = wasm_i8x16_sub(vx, voffset); |
| 192 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable8, vx)); |
| 193 |
|
| 194 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 195 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable9, vx)); |
| 196 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 197 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableA, vx)); |
| 198 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 199 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableB, vx)); |
| 200 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 201 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableC, vx)); |
| 202 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 203 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableD, vx)); |
| 204 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 205 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableE, vx)); |
| 206 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 207 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableF, vx)); |
| 208 |
|
| 209 |
wasm_v128_store(output, vy); |
| 210 |
output += 16; |
| 211 |
} |
| 212 |
if XNN_UNLIKELY(batch != 0) { |
| 213 |
v128_t vx = wasm_v128_load((const v128_t*) input); |
| 214 |
|
| 215 |
v128_t vy = wasm_i8x16_relaxed_swizzle(vtable0, vx); |
| 216 |
|
| 217 |
vx = wasm_i8x16_sub(vx, voffset); |
| 218 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable1, vx)); |
| 219 |
vx = wasm_i8x16_sub(vx, voffset); |
| 220 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable2, vx)); |
| 221 |
vx = wasm_i8x16_sub(vx, voffset); |
| 222 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable3, vx)); |
| 223 |
vx = wasm_i8x16_sub(vx, voffset); |
| 224 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable4, vx)); |
| 225 |
vx = wasm_i8x16_sub(vx, voffset); |
| 226 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable5, vx)); |
| 227 |
vx = wasm_i8x16_sub(vx, voffset); |
| 228 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable6, vx)); |
| 229 |
vx = wasm_i8x16_sub(vx, voffset); |
| 230 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable7, vx)); |
| 231 |
vx = wasm_i8x16_sub(vx, voffset); |
| 232 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable8, vx)); |
| 233 |
|
| 234 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 235 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtable9, vx)); |
| 236 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 237 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableA, vx)); |
| 238 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 239 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableB, vx)); |
| 240 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 241 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableC, vx)); |
| 242 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 243 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableD, vx)); |
| 244 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 245 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableE, vx)); |
| 246 |
vx = wasm_i8x16_sub_sat(vx, voffset); |
| 247 |
vy = wasm_v128_xor(vy, wasm_i8x16_relaxed_swizzle(vtableF, vx)); |
| 248 |
|
| 249 |
if (batch & (8 * sizeof(uint8_t))) { |
| 250 |
wasm_v128_store64_lane(output, vy, 0); |
| 251 |
vy = wasm_v64x2_shuffle(vy, vy, 1, 1); |
| 252 |
output += 8; |
| 253 |
} |
| 254 |
if (batch & (4 * sizeof(uint8_t))) { |
| 255 |
wasm_v128_store32_lane(output, vy, 0); |
| 256 |
vy = wasm_u64x2_shr(vy, 32); |
| 257 |
output += 4; |
| 258 |
} |
| 259 |
if (batch & (2 * sizeof(uint8_t))) { |
| 260 |
wasm_v128_store16_lane(output, vy, 0); |
| 261 |
vy = wasm_u32x4_shr(vy, 16); |
| 262 |
output += 2; |
| 263 |
} |
| 264 |
if (batch & (1 * sizeof(uint8_t))) { |
| 265 |
wasm_v128_store8_lane(output, vy, 0); |
| 266 |
} |
| 267 |
} |
| 268 |
} |