From: Pavel P Date: Sat, 18 Jan 2025 19:32:30 +0000 (+0200) Subject: Use _bzhi_u32 for 32-bit builds when building with STATIC_BMI2 X-Git-Tag: v1.5.7^2~29^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee17f4c6d295e82733673f824e7dba81a33e245b;p=thirdparty%2Fzstd.git Use _bzhi_u32 for 32-bit builds when building with STATIC_BMI2 `_bzhi_u64` is available only for 64-bit builds, while `BIT_getLowerBits` expects `nbBits` to be less than `BIT_MASK_SIZE` (`BIT_MASK_SIZE` is 32) --- diff --git a/lib/common/bitstream.h b/lib/common/bitstream.h index a1dac889d..c9c645416 100644 --- a/lib/common/bitstream.h +++ b/lib/common/bitstream.h @@ -162,7 +162,11 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC, FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits) { #if defined(STATIC_BMI2) && STATIC_BMI2 == 1 && !defined(ZSTD_NO_INTRINSICS) - return _bzhi_u64(bitContainer, nbBits); +#if defined(__x86_64__) || defined(_M_X64) + return _bzhi_u64(bitContainer, nbBits); +#else + return _bzhi_u32(bitContainer, nbBits); +#endif #else assert(nbBits < BIT_MASK_SIZE); return bitContainer & BIT_mask[nbBits];