Debian Codegraph @

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