From: Nathan Moinvaziri Date: Fri, 7 Mar 2025 03:03:11 +0000 (-0800) Subject: Disable MSVC optimizations for AVX512 GET_CHUNK_MAG #1883 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f136e3c86b62e65e699ee8c99863f711693a6aec;p=thirdparty%2Fzlib-ng.git Disable MSVC optimizations for AVX512 GET_CHUNK_MAG #1883 MSVC compiler (VS 17.11.x) incorrectly optimizes the GET_CHUNK_MAG code on older versions. Appears to be resolved in VS 17.13.2. The compiler would optimize the code in such a way that it would cause a decompression failure. It only happens when /Os flag is set. --- diff --git a/arch/x86/chunkset_avx512.c b/arch/x86/chunkset_avx512.c index 9d28d33d..db8c1eb2 100644 --- a/arch/x86/chunkset_avx512.c +++ b/arch/x86/chunkset_avx512.c @@ -98,6 +98,10 @@ static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len return out; } +/* MSVC compiler decompression bug when optimizing for size */ +#if defined(_MSC_VER) && _MSC_VER < 1943 +# pragma optimize("", off) +#endif static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t dist) { lut_rem_pair lut_rem = perm_idx_lut[dist - 3]; __m256i ret_vec; @@ -128,6 +132,9 @@ static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t return ret_vec; } +#if defined(_MSC_VER) && _MSC_VER < 1943 +# pragma optimize("", on) +#endif static inline void storehalfchunk(uint8_t *out, halfchunk_t *chunk) { _mm_storeu_si128((__m128i *)out, *chunk);