From: Nathan Moin Vaziri Date: Fri, 17 Apr 2026 20:23:52 +0000 (-0700) Subject: Merge duplicate 32-bit _mm_cvtsi64_si128 polyfills X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c5cc72e496833f2b2a7db495ca19a5b326924a6;p=thirdparty%2Fzlib-ng.git Merge duplicate 32-bit _mm_cvtsi64_si128 polyfills The MSVC and GCC 32-bit polyfills for _mm_cvtsi64_si128 / _mm_cvtsi128_si64 had identical bodies. Merge them into a single block guarded by !__clang__ && ARCH_32BIT, with the MSVC-only #include nested inside. Co-Authored-By: Claude Opus 4.7 (1M context) --- diff --git a/arch/x86/x86_intrins.h b/arch/x86/x86_intrins.h index a28e3cf74..4f6b7540d 100644 --- a/arch/x86/x86_intrins.h +++ b/arch/x86/x86_intrins.h @@ -100,25 +100,15 @@ static inline __m512i _mm512_zextsi128_si512(__m128i a) { * corruption. _mm_loadl_epi64 compiles to a single MOVQ xmm,m64 that * bypasses the buggy synthesis path. Fixed in VS 2022 17.11 (v143). * - * MSVC only defines _mm_cvtsi64_si128 / _mm_cvtsi128_si64 on 64-bit, so the - * 32-bit polyfills below are also needed for basic compilation. + * GCC and MSVC only define _mm_cvtsi64_si128 / _mm_cvtsi128_si64 on 64-bit, + * so the 32-bit polyfills below are also needed for basic compilation. * * https://developercommunity.visualstudio.com/t/10853479 */ -#if defined(_MSC_VER) && !defined(__clang__) && defined(ARCH_32BIT) +#if !defined(__clang__) && defined(ARCH_32BIT) +#ifdef _MSC_VER #include -static inline int64_t _mm_cvtsi128_si64(__m128i a) { - union { __m128i v; int64_t i; } u; - u.v = a; - return u.i; -} - -static inline __m128i _mm_cvtsi64_si128(int64_t a) { - return _mm_loadl_epi64((const __m128i*)&a); -} #endif - -#if defined(__GNUC__) && !defined(__clang__) && defined(ARCH_32BIT) static inline int64_t _mm_cvtsi128_si64(__m128i a) { union { __m128i v; int64_t i; } u; u.v = a;