Debian Codegraph @

src/x8-lut/gen/x8-lut-avx512skx-vpshufb-u64.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/avx512skx-vpshufb.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 <immintrin.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__avx512skx_vpshufb_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 __m512i vt0 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) table));
31 const __m512i vt1 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 16)));
32 const __m512i vt2 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 32)));
33 const __m512i vt3 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 48)));
34 const __m512i vt4 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 64)));
35 const __m512i vt5 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 80)));
36 const __m512i vt6 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 96)));
37 const __m512i vt7 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 112)));
38 const __m512i vt8 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 128)));
39 const __m512i vt9 = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 144)));
40 const __m512i vtA = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 160)));
41 const __m512i vtB = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 176)));
42 const __m512i vtC = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 192)));
43 const __m512i vtD = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 208)));
44 const __m512i vtE = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 224)));
45 const __m512i vtF = _mm512_broadcast_i32x4(_mm_load_si128((const __m128i*) (table + 240)));
46
47 const __m512i vtable0 = vt0;
48 const __m512i vtable1 = _mm512_xor_si512(vt0, vt1);
49 const __m512i vtable2 = _mm512_xor_si512(vt1, vt2);
50 const __m512i vtable3 = _mm512_xor_si512(vt2, vt3);
51 const __m512i vtable4 = _mm512_xor_si512(vt3, vt4);
52 const __m512i vtable5 = _mm512_xor_si512(vt4, vt5);
53 const __m512i vtable6 = _mm512_xor_si512(vt5, vt6);
54 const __m512i vtable7 = _mm512_xor_si512(vt6, vt7);
55 const __m512i vtable8 = _mm512_xor_si512(_mm512_xor_si512(vt7, vt8), vtable0);
56 const __m512i vtable9 = _mm512_xor_si512(_mm512_xor_si512(vt8, vt9), vtable1);
57 const __m512i vtableA = _mm512_xor_si512(_mm512_xor_si512(vt9, vtA), vtable2);
58 const __m512i vtableB = _mm512_xor_si512(_mm512_xor_si512(vtA, vtB), vtable3);
59 const __m512i vtableC = _mm512_xor_si512(_mm512_xor_si512(vtB, vtC), vtable4);
60 const __m512i vtableD = _mm512_xor_si512(_mm512_xor_si512(vtC, vtD), vtable5);
61 const __m512i vtableE = _mm512_xor_si512(_mm512_xor_si512(vtD, vtE), vtable6);
62 const __m512i vtableF = _mm512_xor_si512(_mm512_xor_si512(vtE, vtF), vtable7);
63
64 const __m512i voffset = _mm512_set1_epi8(16);
65 for (; batch >= 64 * sizeof(uint8_t); batch -= 64 * sizeof(uint8_t)) {
66 __m512i vx = _mm512_loadu_si512(input);
67 input += 64;
68
69 __m512i vy = _mm512_shuffle_epi8(vtable0, vx);
70
71 vx = _mm512_sub_epi8(vx, voffset);
72 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable1, vx));
73 vx = _mm512_sub_epi8(vx, voffset);
74 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable2, vx));
75 vx = _mm512_sub_epi8(vx, voffset);
76 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable3, vx));
77 vx = _mm512_sub_epi8(vx, voffset);
78 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable4, vx));
79 vx = _mm512_sub_epi8(vx, voffset);
80 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable5, vx));
81 vx = _mm512_sub_epi8(vx, voffset);
82 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable6, vx));
83 vx = _mm512_sub_epi8(vx, voffset);
84 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable7, vx));
85 vx = _mm512_sub_epi8(vx, voffset);
86 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable8, vx));
87
88 vx = _mm512_subs_epi8(vx, voffset);
89 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable9, vx));
90 vx = _mm512_subs_epi8(vx, voffset);
91 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableA, vx));
92 vx = _mm512_subs_epi8(vx, voffset);
93 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableB, vx));
94 vx = _mm512_subs_epi8(vx, voffset);
95 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableC, vx));
96 vx = _mm512_subs_epi8(vx, voffset);
97 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableD, vx));
98 vx = _mm512_subs_epi8(vx, voffset);
99 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableE, vx));
100 vx = _mm512_subs_epi8(vx, voffset);
101 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableF, vx));
102
103 _mm512_storeu_si512(output, vy);
104 output += 64;
105 }
106 if XNN_UNLIKELY(batch != 0) {
107 assert(batch < 64);
108 const __mmask64 vmask = _cvtu64_mask64((uint64_t) ((UINT64_C(1) << batch) - UINT64_C(1)));
109
110 __m512i vx = _mm512_maskz_loadu_epi8(vmask, input);
111
112 __m512i vy = _mm512_shuffle_epi8(vtable0, vx);
113
114 vx = _mm512_sub_epi8(vx, voffset);
115 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable1, vx));
116 vx = _mm512_sub_epi8(vx, voffset);
117 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable2, vx));
118 vx = _mm512_sub_epi8(vx, voffset);
119 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable3, vx));
120 vx = _mm512_sub_epi8(vx, voffset);
121 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable4, vx));
122 vx = _mm512_sub_epi8(vx, voffset);
123 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable5, vx));
124 vx = _mm512_sub_epi8(vx, voffset);
125 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable6, vx));
126 vx = _mm512_sub_epi8(vx, voffset);
127 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable7, vx));
128 vx = _mm512_sub_epi8(vx, voffset);
129 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable8, vx));
130
131 vx = _mm512_subs_epi8(vx, voffset);
132 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtable9, vx));
133 vx = _mm512_subs_epi8(vx, voffset);
134 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableA, vx));
135 vx = _mm512_subs_epi8(vx, voffset);
136 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableB, vx));
137 vx = _mm512_subs_epi8(vx, voffset);
138 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableC, vx));
139 vx = _mm512_subs_epi8(vx, voffset);
140 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableD, vx));
141 vx = _mm512_subs_epi8(vx, voffset);
142 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableE, vx));
143 vx = _mm512_subs_epi8(vx, voffset);
144 vy = _mm512_xor_si512(vy, _mm512_shuffle_epi8(vtableF, vx));
145
146 _mm512_mask_storeu_epi8(output, vmask, vy);
147 }
148 }