Debian Codegraph @

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

raw
1 /* compare256_rvv.c - RVV version of compare256
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 "../../zbuild.h"
10 #include "fallback_builtins.h"
11
12 #include <riscv_vector.h>
13
14 static inline uint32_t compare256_rvv_static(const uint8_t *src0, const uint8_t *src1) {
15 uint32_t len = 0;
16 size_t vl;
17 long found_diff;
18 do {
19 vl = __riscv_vsetvl_e8m4(256 - len);
20 vuint8m4_t v_src0 = __riscv_vle8_v_u8m4(src0, vl);
21 vuint8m4_t v_src1 = __riscv_vle8_v_u8m4(src1, vl);
22 vbool2_t v_mask = __riscv_vmsne_vv_u8m4_b2(v_src0, v_src1, vl);
23 found_diff = __riscv_vfirst_m_b2(v_mask, vl);
24 if (found_diff >= 0)
25 return len + (uint32_t)found_diff;
26 src0 += vl, src1 += vl, len += vl;
27 } while (len < 256);
28
29 return 256;
30 }
31
32 Z_INTERNAL uint32_t compare256_rvv(const uint8_t *src0, const uint8_t *src1) {
33 return compare256_rvv_static(src0, src1);
34 }
35
36 #define LONGEST_MATCH longest_match_rvv
37 #define COMPARE256 compare256_rvv_static
38
39 #include "match_tpl.h"
40
41 #define LONGEST_MATCH_SLOW
42 #define LONGEST_MATCH longest_match_slow_rvv
43 #define COMPARE256 compare256_rvv_static
44
45 #include "match_tpl.h"
46
47 #endif // RISCV_RVV