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)
This commit is contained in:
Pavel P
2025-01-18 21:33:04 +02:00
parent c8243b4724
commit ee17f4c6d2
+5 -1
View File
@@ -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];