| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 033f1e2 commit 569a739
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -151,7 +151,13 @@ if (use_arm_neon_optimizations) { | |||
| 151 | 151 | if (!is_win && !is_clang) { | |
| 152 | 152 | assert(!use_thin_lto, | |
| 153 | 153 | "ThinLTO fails mixing different module-level targets") | |
| 154 | - cflags_c = [ "-march=armv8-a+aes+crc" ] | ||
| 154 | + if (current_cpu == "arm64") { | ||
| 155 | + cflags_c = [ "-march=armv8-a+aes+crc" ] | ||
| 156 | + } else if (current_cpu == "arm") { | ||
| 157 | + cflags_c = [ "-march=armv8-a+crc" ] | ||
| 158 | + } else { | ||
| 159 | + assert(false, "Unexpected cpu: $current_cpu") | ||
| 160 | + } | ||
| 155 | 161 | } | |
| 156 | 162 | ||
| 157 | 163 | sources = [ | |
@@ -478,9 +484,7 @@ if (!is_win || target_os != "winuwp") { | |||
| 478 | 484 | sources = [ "contrib/minizip/minizip.c" ] | |
| 479 | 485 | ||
| 480 | 486 | if (is_clang) { | |
| 481 | - cflags = [ | ||
| 482 | - "-Wno-incompatible-pointer-types-discards-qualifiers", | ||
| 483 | - ] | ||
| 487 | + cflags = [ "-Wno-incompatible-pointer-types-discards-qualifiers" ] | ||
| 484 | 488 | } | |
| 485 | 489 | ||
| 486 | 490 | if (!is_debug) { | |
@@ -500,9 +504,7 @@ if (!is_win || target_os != "winuwp") { | |||
| 500 | 504 | sources = [ "contrib/minizip/miniunz.c" ] | |
| 501 | 505 | ||
| 502 | 506 | if (is_clang) { | |
| 503 | - cflags = [ | ||
| 504 | - "-Wno-incompatible-pointer-types-discards-qualifiers", | ||
| 505 | - ] | ||
| 507 | + cflags = [ "-Wno-incompatible-pointer-types-discards-qualifiers" ] | ||
| 506 | 508 | } | |
| 507 | 509 | ||
| 508 | 510 | if (!is_debug) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -700,24 +700,29 @@ local z_word_t crc_word_big(z_word_t data) { | |||
| 700 | 700 | /* ========================================================================= */ | |
| 701 | 701 | unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, | |
| 702 | 702 | z_size_t len) { | |
| 703 | + | ||
| 704 | + /* If no optimizations are enabled, do it as canonical zlib. */ | ||
| 705 | + #if !defined(CRC32_SIMD_SSE42_PCLMUL) && !defined(CRC32_ARMV8_CRC32) && \ | ||
| 706 | + !defined(RISCV_RVV) && !defined(CRC32_SIMD_AVX512_PCLMUL) | ||
| 707 | + if (buf == Z_NULL) { | ||
| 708 | + return 0UL; | ||
| 709 | + } | ||
| 710 | + #else | ||
| 703 | 711 | /* | |
| 704 | 712 | * zlib convention is to call crc32(0, NULL, 0); before making | |
| 705 | 713 | * calls to crc32(). So this is a good, early (and infrequent) | |
| 706 | 714 | * place to cache CPU features if needed for those later, more | |
| 707 | 715 | * interesting crc32() calls. | |
| 708 | 716 | */ | |
| 709 | - #if defined(CRC32_SIMD_SSE42_PCLMUL) || defined(CRC32_ARMV8_CRC32) \ | ||
| 710 | - || defined(RISCV_RVV) | ||
| 711 | - /* | ||
| 712 | - * Since this routine can be freely used, check CPU features here. | ||
| 713 | - */ | ||
| 714 | 717 | if (buf == Z_NULL) { | |
| 715 | - if (!len) /* Assume user is calling crc32(0, NULL, 0); */ | ||
| 718 | + if (!len) | ||
| 716 | 719 | cpu_check_features(); | |
| 717 | 720 | return 0UL; | |
| 718 | 721 | } | |
| 719 | - | ||
| 720 | 722 | #endif | |
| 723 | + /* If AVX-512 is enabled, we will use it for longer inputs and fallback | ||
| 724 | + * to SSE4.2 and eventually the portable implementation to handle the tail. | ||
| 725 | + */ | ||
| 721 | 726 | #if defined(CRC32_SIMD_AVX512_PCLMUL) | |
| 722 | 727 | if (x86_cpu_enable_avx512 && len >= Z_CRC32_AVX512_MINIMUM_LENGTH) { | |
| 723 | 728 | /* crc32 64-byte chunks */ | |
@@ -730,7 +735,8 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, | |||
| 730 | 735 | /* Fall into the default crc32 for the remaining data. */ | |
| 731 | 736 | buf += chunk_size; | |
| 732 | 737 | } | |
| 733 | - #elif defined(CRC32_SIMD_SSE42_PCLMUL) | ||
| 738 | + #endif | ||
| 739 | + #if defined(CRC32_SIMD_SSE42_PCLMUL) | ||
| 734 | 740 | if (x86_cpu_enable_simd && len >= Z_CRC32_SSE42_MINIMUM_LENGTH) { | |
| 735 | 741 | /* crc32 16-byte chunks */ | |
| 736 | 742 | z_size_t chunk_size = len & ~Z_CRC32_SSE42_CHUNKSIZE_MASK; | |
@@ -758,11 +764,8 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, | |||
| 758 | 764 | buf += chunk_size; | |
| 759 | 765 | } | |
| 760 | 766 | #endif | |
| 761 | - return armv8_crc32_little(buf, len, crc); /* Armv8@32bit or tail. */ | ||
| 762 | - } | ||
| 763 | - #else | ||
| 764 | - if (buf == Z_NULL) { | ||
| 765 | - return 0UL; | ||
| 767 | + /* This is scalar and self contained, used on Armv8@32bit or tail. */ | ||
| 768 | + return armv8_crc32_little(buf, len, crc); | ||
| 766 | 769 | } | |
| 767 | 770 | #endif /* CRC32_SIMD */ | |
| 768 | 771 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -200,7 +200,8 @@ uint32_t ZLIB_INTERNAL crc32_avx512_simd_( /* AVX512+PCLMUL */ | |||
| 200 | 200 | return _mm_extract_epi32(a1, 1); | |
| 201 | 201 | } | |
| 202 | 202 | ||
| 203 | - #elif defined(CRC32_SIMD_SSE42_PCLMUL) | ||
| 203 | + #endif | ||
| 204 | + #if defined(CRC32_SIMD_SSE42_PCLMUL) | ||
| 204 | 205 | ||
| 205 | 206 | /* | |
| 206 | 207 | * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer | |
| Back | FazBrowse Home | New Git URL |
0 commit comments