]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
Fix MSVC v142 miscompile of _mm_cvtsi64_si128 polyfill on 32-bit
authorNathan Moin Vaziri <nathan@nathanm.com>
Fri, 17 Apr 2026 20:22:49 +0000 (13:22 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 22 Apr 2026 09:40:20 +0000 (11:40 +0200)
commit059db39af33efca05cd552cff114aa3e755842e1
treea277d881f8b97ec767c22e76a7720e877b7f92ec
parentd1afe3a6f7cb51c6cd4aaec2189b9e2ce267fbfe
Fix MSVC v142 miscompile of _mm_cvtsi64_si128 polyfill on 32-bit

MSVC v142 (Visual Studio 2019, and VS 2022 pre-17.11) miscompiles
_mm_set_epi64x(0, a) on 32-bit Windows by routing part of the synthesis
through a GPR, clobbering live register data and causing stack corruption
in the chorba SSE2/SSE4.1 CRC32 code paths.

Replace the _mm_set_epi64x(0, a) polyfill with _mm_loadl_epi64 which
compiles to a single MOVQ xmm,m64 that bypasses the buggy synthesis
path. Also convert the GCC 32-bit _mm_cvtsi64_si128 macro to a static
inline for consistency, and drop the redundant ARCH_X86 guard since
x86_intrins.h is only reachable from x86 code.

https://developercommunity.visualstudio.com/t/10853479

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
arch/x86/x86_intrins.h