Debian Codegraph @

Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/riscv/slide_hash_rvv.c

raw
1 /* slide_hash_rvv.c - RVV version of slide_hash
2 * Copyright (C) 2023 SiFive, Inc. All rights reserved.
3 * Contributed by Alex Chiang <[email protected]>
4 * For conditions of distribution and use, see copyright notice in zlib.h
5 */
6
7 #ifdef RISCV_RVV
8
9 #include <riscv_vector.h>
10
11 #include "../../zbuild.h"
12 #include "../../deflate.h"
13
14 static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) {
15 size_t vl;
16 while (entries > 0) {
17 vl = __riscv_vsetvl_e16m4(entries);
18 vuint16m4_t v_tab = __riscv_vle16_v_u16m4(table, vl);
19 vuint16m4_t v_diff = __riscv_vsub_vx_u16m4(v_tab, wsize, vl);
20 vbool4_t mask = __riscv_vmsltu_vx_u16m4_b4(v_tab, wsize, vl);
21 v_tab = __riscv_vmerge_vxm_u16m4(v_diff, 0, mask, vl);
22 __riscv_vse16_v_u16m4(table, v_tab, vl);
23 table += vl, entries -= vl;
24 }
25 }
26
27 Z_INTERNAL void slide_hash_rvv(deflate_state *s) {
28 uint16_t wsize = (uint16_t)s->w_size;
29
30 slide_hash_chain(s->head, HASH_SIZE, wsize);
31 slide_hash_chain(s->prev, wsize, wsize);
32 }
33
34 #endif // RISCV_RVV