| 1 | /* compare256_avx2.c -- AVX2 version of compare256 |
| 2 | * Copyright Mika T. Lindqvist <[email protected]> |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "../../zbuild.h"cxx . . $ `<file>/Modules/ThirdParty/ZLIB/src/itkzlib-ng/zbuild.h`/ |
| 7 | |
| 8 | #include "fallback_builtins.h"cxx . . $ `<file>/Modules/ThirdParty/ZLIB/src/itkzlib-ng/fallback_builtins.h`/ |
| 9 | |
| 10 | #if defined(X86_AVX2cxx . . $ `<built-in>:427:9`!) && defined(HAVE_BUILTIN_CTZcxx . . $ `<built-in>:420:9`!) |
| 11 | |
| 12 | #include <immintrin.h> |
| 13 | #ifdef _MSC_VER |
| 14 | # include <nmmintrin.h> |
| 15 | #endif |
| 16 | |
| 17 | static inline uint32_tcxx . . $ uint32_t# compare256_avx2_staticcxx . . $ compare256_avx2_static(922916fe7731ea47).(const uint8_tcxx . . $ uint8_t# *src0, const uint8_tcxx . . $ uint8_t# *src1) { |
| 18 | uint32_tcxx . . $ uint32_t# len = 0; |
| 19 | |
| 20 | do { |
| 21 | __m256icxx . . $ __m256i# ymm_src0, ymm_src1, ymm_cmp; |
| 22 | ymm_src0 = _mm256_loadu_si256cxx . . $ _mm256_loadu_si256(181560bb045879).((__m256icxx . . $ __m256i#*)src0); |
| 23 | ymm_src1 = _mm256_loadu_si256cxx . . $ _mm256_loadu_si256(181560bb045879).((__m256icxx . . $ __m256i#*)src1); |
| 24 | ymm_cmp = _mm256_cmpeq_epi8cxx . . $ _mm256_cmpeq_epi8(45577336e34aacfa).(ymm_src0, ymm_src1); /* non-identical bytes = 00, identical bytes = FF */ |
| 25 | unsigned mask = (unsigned)_mm256_movemask_epi8cxx . . $ _mm256_movemask_epi8(638107abaed0c6b5).(ymm_cmp); |
| 26 | if (mask != 0xFFFFFFFF) { |
| 27 | uint32_tcxx . . $ uint32_t# match_byte = (uint32_tcxx . . $ uint32_t#)__builtin_ctzcxx . . $ __builtin_ctz(4c679297bf94b9eb).(~mask); /* Invert bits so identical = 0 */ |
| 28 | return len + match_byte; |
| 29 | } |
| 30 | |
| 31 | src0 += 32, src1 += 32, len += 32; |
| 32 | |
| 33 | ymm_src0 = _mm256_loadu_si256cxx . . $ _mm256_loadu_si256(181560bb045879).((__m256icxx . . $ __m256i#*)src0); |
| 34 | ymm_src1 = _mm256_loadu_si256cxx . . $ _mm256_loadu_si256(181560bb045879).((__m256icxx . . $ __m256i#*)src1); |
| 35 | ymm_cmp = _mm256_cmpeq_epi8cxx . . $ _mm256_cmpeq_epi8(45577336e34aacfa).(ymm_src0, ymm_src1); |
| 36 | mask = (unsigned)_mm256_movemask_epi8cxx . . $ _mm256_movemask_epi8(638107abaed0c6b5).(ymm_cmp); |
| 37 | if (mask != 0xFFFFFFFF) { |
| 38 | uint32_tcxx . . $ uint32_t# match_byte = (uint32_tcxx . . $ uint32_t#)__builtin_ctzcxx . . $ __builtin_ctz(4c679297bf94b9eb).(~mask); |
| 39 | return len + match_byte; |
| 40 | } |
| 41 | |
| 42 | src0 += 32, src1 += 32, len += 32; |
| 43 | } while (len < 256); |
| 44 | |
| 45 | return 256; |
| 46 | } |
| 47 | |
| 48 | Z_INTERNALcxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/zbuild.h:109:11`! uint32_tcxx . . $ uint32_t# compare256_avx2cxx . . $ compare256_avx2(922916fe7731ea47).(const uint8_tcxx . . $ uint8_t# *src0, const uint8_tcxx . . $ uint8_t# *src1) { |
| 49 | return compare256_avx2_staticcxx . . $ compare256_avx2_static(922916fe7731ea47).(src0, src1); |
| 50 | } |
| 51 | |
| 52 | #define LONGEST_MATCHcxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/x86/compare256_avx2.c:52:9`! longest_match_avx2 |
| 53 | #define COMPARE256cxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/x86/compare256_avx2.c:53:9`! compare256_avx2_static |
| 54 | |
| 55 | #include "match_tpl.h"cxx . . $ `<file>/Modules/ThirdParty/ZLIB/src/itkzlib-ng/match_tpl.h`/ |
| 56 | |
| 57 | #define LONGEST_MATCH_SLOWcxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/x86/compare256_avx2.c:57:9`! |
| 58 | #define LONGEST_MATCHcxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/x86/compare256_avx2.c:58:9`! longest_match_slow_avx2 |
| 59 | #define COMPARE256cxx . . $ `Modules/ThirdParty/ZLIB/src/itkzlib-ng/arch/x86/compare256_avx2.c:59:9`! compare256_avx2_static |
| 60 | |
| 61 | #include "match_tpl.h"cxx . . $ `<file>/Modules/ThirdParty/ZLIB/src/itkzlib-ng/match_tpl.h`/ |
| 62 | |
| 63 | #endif |