Debian Codegraph @

src/x8-lut/gen/x8-lut-aarch64-neon-tbx128x4-u16.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/neon-tbx128x4.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 <arm_neon.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__aarch64_neon_tbx128x4_u16(
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 uint8x16x4_t vtable0123 = vld1q_u8_x4(table);
31 const uint8x16x4_t vtable4567 = vld1q_u8_x4(table + 64);
32 const uint8x16x4_t vtable89AB = vld1q_u8_x4(table + 128);
33 const uint8x16x4_t vtableCDEF = vld1q_u8_x4(table + 192);
34 const uint8x16_t voffset = vmovq_n_u8(64);
35 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
36 uint8x16_t vx = vld1q_u8(input); input += 16;
37
38 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
39
40 vx = vsubq_u8(vx, voffset);
41 vy = vqtbx4q_u8(vy, vtable4567, vx);
42
43 vx = vsubq_u8(vx, voffset);
44 vy = vqtbx4q_u8(vy, vtable89AB, vx);
45
46 vx = vsubq_u8(vx, voffset);
47 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
48
49 vst1q_u8(output, vy); output += 16;
50 }
51 if XNN_UNLIKELY(batch != 0) {
52 uint8x16_t vx = vld1q_u8(input);
53
54 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
55
56 vx = vsubq_u8(vx, voffset);
57 vy = vqtbx4q_u8(vy, vtable4567, vx);
58
59 vx = vsubq_u8(vx, voffset);
60 vy = vqtbx4q_u8(vy, vtable89AB, vx);
61
62 vx = vsubq_u8(vx, voffset);
63 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
64
65 uint8x8_t vy_lo = vget_low_u8(vy);
66 if (batch & (8 * sizeof(uint8_t))) {
67 vst1_u8(output, vy_lo); output += 8;
68 vy_lo = vget_high_u8(vy);
69 }
70 if (batch & (4 * sizeof(uint8_t))) {
71 vst1_lane_u32((void*) output, vreinterpret_u32_u8(vy_lo), 0); output += 4;
72 vy_lo = vext_u8(vy_lo, vy_lo, 4);
73 }
74 if (batch & (2 * sizeof(uint8_t))) {
75 vst1_lane_u16((void*) output, vreinterpret_u16_u8(vy_lo), 0); output += 2;
76 vy_lo = vext_u8(vy_lo, vy_lo, 2);
77 }
78 if (batch & (1 * sizeof(uint8_t))) {
79 vst1_lane_u8(output, vy_lo, 0);
80 }
81 }
82 }