Debian Codegraph @

Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/arm/compare256_neon.c

raw
1 /* compare256_neon.c - NEON version of compare256
2 * Copyright (C) 2022 Nathan Moinvaziri
3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */
5
6 #include "../../zbuild.h"
7
8 #include "fallback_builtins.h"
9
10 #if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL)
11 #include "neon_intrins.h"
12
13 static inline uint32_t compare256_neon_static(const uint8_t *src0, const uint8_t *src1) {
14 uint32_t len = 0;
15
16 do {
17 uint8x16_t a, b, cmp;
18 uint64_t lane;
19
20 a = vld1q_u8(src0);
21 b = vld1q_u8(src1);
22
23 cmp = veorq_u8(a, b);
24
25 lane = vgetq_lane_u64(vreinterpretq_u64_u8(cmp), 0);
26 if (lane) {
27 uint32_t match_byte = (uint32_t)__builtin_ctzll(lane) / 8;
28 return len + match_byte;
29 }
30 len += 8;
31 lane = vgetq_lane_u64(vreinterpretq_u64_u8(cmp), 1);
32 if (lane) {
33 uint32_t match_byte = (uint32_t)__builtin_ctzll(lane) / 8;
34 return len + match_byte;
35 }
36 len += 8;
37
38 src0 += 16, src1 += 16;
39 } while (len < 256);
40
41 return 256;
42 }
43
44 Z_INTERNAL uint32_t compare256_neon(const uint8_t *src0, const uint8_t *src1) {
45 return compare256_neon_static(src0, src1);
46 }
47
48 #define LONGEST_MATCH longest_match_neon
49 #define COMPARE256 compare256_neon_static
50
51 #include "match_tpl.h"
52
53 #define LONGEST_MATCH_SLOW
54 #define LONGEST_MATCH longest_match_slow_neon
55 #define COMPARE256 compare256_neon_static
56
57 #include "match_tpl.h"
58
59 #endif