From d0652423c1d444ec6256c05a1ea805640cc2d337 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Thu, 6 Mar 2025 19:03:11 -0800 Subject: [PATCH] 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. --- arch/x86/chunkset_avx512.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.47.3