Debian Codegraph @

src/x8-lut/gen/x8-lut-aarch64-neon-tbx128x4-u48.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_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 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 >= 48 * sizeof(uint8_t); batch -= 48 * sizeof(uint8_t)) {
36 uint8x16_t vx0 = vld1q_u8(input); input += 16;
37 uint8x16_t vx1 = vld1q_u8(input); input += 16;
38 uint8x16_t vx2 = vld1q_u8(input); input += 16;
39
40 uint8x16_t vy0 = vqtbl4q_u8(vtable0123, vx0);
41 vx0 = vsubq_u8(vx0, voffset);
42 uint8x16_t vy1 = vqtbl4q_u8(vtable0123, vx1);
43 vx1 = vsubq_u8(vx1, voffset);
44 uint8x16_t vy2 = vqtbl4q_u8(vtable0123, vx2);
45 vx2 = vsubq_u8(vx2, voffset);
46
47 vy0 = vqtbx4q_u8(vy0, vtable4567, vx0);
48 vx0 = vsubq_u8(vx0, voffset);
49 vy1 = vqtbx4q_u8(vy1, vtable4567, vx1);
50 vx1 = vsubq_u8(vx1, voffset);
51 vy2 = vqtbx4q_u8(vy2, vtable4567, vx2);
52 vx2 = vsubq_u8(vx2, voffset);
53
54 vy0 = vqtbx4q_u8(vy0, vtable89AB, vx0);
55 vx0 = vsubq_u8(vx0, voffset);
56 vy1 = vqtbx4q_u8(vy1, vtable89AB, vx1);
57 vx1 = vsubq_u8(vx1, voffset);
58 vy2 = vqtbx4q_u8(vy2, vtable89AB, vx2);
59 vx2 = vsubq_u8(vx2, voffset);
60
61 vy0 = vqtbx4q_u8(vy0, vtableCDEF, vx0);
62 vy1 = vqtbx4q_u8(vy1, vtableCDEF, vx1);
63 vy2 = vqtbx4q_u8(vy2, vtableCDEF, vx2);
64
65 vst1q_u8(output, vy0); output += 16;
66 vst1q_u8(output, vy1); output += 16;
67 vst1q_u8(output, vy2); output += 16;
68 }
69 for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) {
70 uint8x16_t vx = vld1q_u8(input); input += 16;
71
72 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
73
74 vx = vsubq_u8(vx, voffset);
75 vy = vqtbx4q_u8(vy, vtable4567, vx);
76
77 vx = vsubq_u8(vx, voffset);
78 vy = vqtbx4q_u8(vy, vtable89AB, vx);
79
80 vx = vsubq_u8(vx, voffset);
81 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
82
83 vst1q_u8(output, vy); output += 16;
84 }
85 if XNN_UNLIKELY(batch != 0) {
86 uint8x16_t vx = vld1q_u8(input);
87
88 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
89
90 vx = vsubq_u8(vx, voffset);
91 vy = vqtbx4q_u8(vy, vtable4567, vx);
92
93 vx = vsubq_u8(vx, voffset);
94 vy = vqtbx4q_u8(vy, vtable89AB, vx);
95
96 vx = vsubq_u8(vx, voffset);
97 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
98
99 uint8x8_t vy_lo = vget_low_u8(vy);
100 if (batch & (8 * sizeof(uint8_t))) {
101 vst1_u8(output, vy_lo); output += 8;
102 vy_lo = vget_high_u8(vy);
103 }
104 if (batch & (4 * sizeof(uint8_t))) {
105 vst1_lane_u32((void*) output, vreinterpret_u32_u8(vy_lo), 0); output += 4;
106 vy_lo = vext_u8(vy_lo, vy_lo, 4);
107 }
108 if (batch & (2 * sizeof(uint8_t))) {
109 vst1_lane_u16((void*) output, vreinterpret_u16_u8(vy_lo), 0); output += 2;
110 vy_lo = vext_u8(vy_lo, vy_lo, 2);
111 }
112 if (batch & (1 * sizeof(uint8_t))) {
113 vst1_lane_u8(output, vy_lo, 0);
114 }
115 }
116 }