diff --git a/deps/zlib/BUILD.gn b/deps/zlib/BUILD.gn index f97ab45de2741f..378bd0df75ca22 100644 --- a/deps/zlib/BUILD.gn +++ b/deps/zlib/BUILD.gn @@ -151,7 +151,13 @@ if (use_arm_neon_optimizations) { if (!is_win && !is_clang) { assert(!use_thin_lto, "ThinLTO fails mixing different module-level targets") - cflags_c = [ "-march=armv8-a+aes+crc" ] + if (current_cpu == "arm64") { + cflags_c = [ "-march=armv8-a+aes+crc" ] + } else if (current_cpu == "arm") { + cflags_c = [ "-march=armv8-a+crc" ] + } else { + assert(false, "Unexpected cpu: $current_cpu") + } } sources = [ @@ -478,9 +484,7 @@ if (!is_win || target_os != "winuwp") { sources = [ "contrib/minizip/minizip.c" ] if (is_clang) { - cflags = [ - "-Wno-incompatible-pointer-types-discards-qualifiers", - ] + cflags = [ "-Wno-incompatible-pointer-types-discards-qualifiers" ] } if (!is_debug) { @@ -500,9 +504,7 @@ if (!is_win || target_os != "winuwp") { sources = [ "contrib/minizip/miniunz.c" ] if (is_clang) { - cflags = [ - "-Wno-incompatible-pointer-types-discards-qualifiers", - ] + cflags = [ "-Wno-incompatible-pointer-types-discards-qualifiers" ] } if (!is_debug) { diff --git a/deps/zlib/crc32.c b/deps/zlib/crc32.c index 32686f92488c51..4177e920a479df 100644 --- a/deps/zlib/crc32.c +++ b/deps/zlib/crc32.c @@ -700,24 +700,29 @@ local z_word_t crc_word_big(z_word_t data) { /* ========================================================================= */ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, z_size_t len) { + + /* If no optimizations are enabled, do it as canonical zlib. */ +#if !defined(CRC32_SIMD_SSE42_PCLMUL) && !defined(CRC32_ARMV8_CRC32) && \ + !defined(RISCV_RVV) && !defined(CRC32_SIMD_AVX512_PCLMUL) + if (buf == Z_NULL) { + return 0UL; + } +#else /* * zlib convention is to call crc32(0, NULL, 0); before making * calls to crc32(). So this is a good, early (and infrequent) * place to cache CPU features if needed for those later, more * interesting crc32() calls. */ -#if defined(CRC32_SIMD_SSE42_PCLMUL) || defined(CRC32_ARMV8_CRC32) \ - || defined(RISCV_RVV) - /* - * Since this routine can be freely used, check CPU features here. - */ if (buf == Z_NULL) { - if (!len) /* Assume user is calling crc32(0, NULL, 0); */ + if (!len) cpu_check_features(); return 0UL; } - #endif + /* If AVX-512 is enabled, we will use it for longer inputs and fallback + * to SSE4.2 and eventually the portable implementation to handle the tail. + */ #if defined(CRC32_SIMD_AVX512_PCLMUL) if (x86_cpu_enable_avx512 && len >= Z_CRC32_AVX512_MINIMUM_LENGTH) { /* crc32 64-byte chunks */ @@ -730,7 +735,8 @@ unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, /* Fall into the default crc32 for the remaining data. */ buf += chunk_size; } -#elif defined(CRC32_SIMD_SSE42_PCLMUL) +#endif +#if defined(CRC32_SIMD_SSE42_PCLMUL) if (x86_cpu_enable_simd && len >= Z_CRC32_SSE42_MINIMUM_LENGTH) { /* crc32 16-byte chunks */ 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, buf += chunk_size; } #endif - return armv8_crc32_little(buf, len, crc); /* Armv8@32bit or tail. */ - } -#else - if (buf == Z_NULL) { - return 0UL; + /* This is scalar and self contained, used on Armv8@32bit or tail. */ + return armv8_crc32_little(buf, len, crc); } #endif /* CRC32_SIMD */ diff --git a/deps/zlib/crc32_simd.c b/deps/zlib/crc32_simd.c index 7428270920a03e..1ee7742015da60 100644 --- a/deps/zlib/crc32_simd.c +++ b/deps/zlib/crc32_simd.c @@ -200,7 +200,8 @@ uint32_t ZLIB_INTERNAL crc32_avx512_simd_( /* AVX512+PCLMUL */ return _mm_extract_epi32(a1, 1); } -#elif defined(CRC32_SIMD_SSE42_PCLMUL) +#endif +#if defined(CRC32_SIMD_SSE42_PCLMUL) /* * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer diff --git a/src/zlib_version.h b/src/zlib_version.h index d8e10e42d265e2..c7e5a26f7a0a78 100644 --- a/src/zlib_version.h +++ b/src/zlib_version.h @@ -2,5 +2,5 @@ // Refer to tools/dep_updaters/update-zlib.sh #ifndef SRC_ZLIB_VERSION_H_ #define SRC_ZLIB_VERSION_H_ -#define ZLIB_VERSION "1.3.0.1-motley-4f653ff" +#define ZLIB_VERSION "1.3.0.1-motley-209717d" #endif // SRC_ZLIB_VERSION_H_