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
xnn_x8_lut_ukernel__neon_tbx128x4_x16(size_t n,const uint8_t * x,uint8_t * y,const uint8_t t[restrict XNN_MIN_ELEMENTS (256)])19 void xnn_x8_lut_ukernel__neon_tbx128x4_x16(
20 size_t n,
21 const uint8_t* x,
22 uint8_t* y,
23 const uint8_t t[restrict XNN_MIN_ELEMENTS(256)])
24 {
25 assert(n != 0);
26 assert(x != NULL);
27 assert(y != NULL);
28
29 const uint8x16x4_t vtable0123 = vld1q_u8_x4(t);
30 const uint8x16x4_t vtable4567 = vld1q_u8_x4(t + 64);
31 const uint8x16x4_t vtable89AB = vld1q_u8_x4(t + 128);
32 const uint8x16x4_t vtableCDEF = vld1q_u8_x4(t + 192);
33 const uint8x16_t voffset = vmovq_n_u8(64);
34 for (; n >= 16 * sizeof(uint8_t); n -= 16 * sizeof(uint8_t)) {
35 uint8x16_t vx = vld1q_u8(x); x += 16;
36
37 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
38
39 vx = vsubq_u8(vx, voffset);
40 vy = vqtbx4q_u8(vy, vtable4567, vx);
41
42 vx = vsubq_u8(vx, voffset);
43 vy = vqtbx4q_u8(vy, vtable89AB, vx);
44
45 vx = vsubq_u8(vx, voffset);
46 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
47
48 vst1q_u8(y, vy); y += 16;
49 }
50 if XNN_UNLIKELY(n != 0) {
51 uint8x16_t vx = vld1q_u8(x);
52
53 uint8x16_t vy = vqtbl4q_u8(vtable0123, vx);
54
55 vx = vsubq_u8(vx, voffset);
56 vy = vqtbx4q_u8(vy, vtable4567, vx);
57
58 vx = vsubq_u8(vx, voffset);
59 vy = vqtbx4q_u8(vy, vtable89AB, vx);
60
61 vx = vsubq_u8(vx, voffset);
62 vy = vqtbx4q_u8(vy, vtableCDEF, vx);
63
64 uint8x8_t vy_lo = vget_low_u8(vy);
65 if (n & (8 * sizeof(uint8_t))) {
66 vst1_u8(y, vy_lo); y += 8;
67 vy_lo = vget_high_u8(vy);
68 }
69 if (n & (4 * sizeof(uint8_t))) {
70 vst1_lane_u32((void*) y, vreinterpret_u32_u8(vy_lo), 0); y += 4;
71 vy_lo = vext_u8(vy_lo, vy_lo, 4);
72 }
73 if (n & (2 * sizeof(uint8_t))) {
74 vst1_lane_u16((void*) y, vreinterpret_u16_u8(vy_lo), 0); y += 2;
75 vy_lo = vext_u8(vy_lo, vy_lo, 2);
76 }
77 if (n & (1 * sizeof(uint8_t))) {
78 vst1_lane_u8(y, vy_lo, 0);
79 }
80 }
81 }
82