Debian Codegraph @

src/x8-lut/gen/x8-lut-avx512vbmi-vpermx2b-u64.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-lut/avx512vbmi-vpermx2b.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__avx512vbmi_vpermx2b_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 vtable0 = _mm512_loadu_si512(table);
31 const __m512i vtable1 = _mm512_loadu_si512(table + 64);
32 const __m512i vtable2 = _mm512_loadu_si512(table + 128);
33 const __m512i vtable3 = _mm512_loadu_si512(table + 192);
34
35 for (; batch >= 64 * sizeof(uint8_t); batch -= 64 * sizeof(uint8_t)) {
36 __m512i vx = _mm512_loadu_si512(input);
37 input += 64;
38
39 __m512i vy = _mm512_permutex2var_epi8(vtable0, vx, vtable1);
40 const __mmask64 vm = _mm512_movepi8_mask(vx);
41 const __m512i vt = _mm512_permutex2var_epi8(vtable2, vx, vtable3);
42 vy = _mm512_mask_mov_epi8(vy, vm, vt);
43
44 _mm512_storeu_si512(output, vy);
45 output += 64;
46 }
47 if XNN_UNLIKELY(batch != 0) {
48 assert(batch < 64);
49 const __mmask64 vmask = _cvtu64_mask64((uint64_t) ((UINT64_C(1) << batch) - UINT64_C(1)));
50
51 __m512i vx = _mm512_maskz_loadu_epi8(vmask, input);
52
53 __m512i vy = _mm512_maskz_permutex2var_epi8(vmask, vtable0, vx, vtable1);
54 const __mmask64 vm = _mm512_movepi8_mask(vx);
55 const __m512i vt = _mm512_maskz_permutex2var_epi8(vmask, vtable2, vx, vtable3);
56 vy = _mm512_mask_mov_epi8(vy, vm, vt);
57
58 _mm512_mask_storeu_epi8(output, vmask, vy);
59 }
60 }