Skip to content

Commit

Permalink
Merge pull request #4248 from pps83/dev-bzhi32
Browse files Browse the repository at this point in the history
Use _bzhi_u32 for 32-bit builds when building with STATIC_BMI2
  • Loading branch information
Cyan4973 authored Jan 19, 2025
2 parents 167b004 + fcd684b commit a469e7c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/common/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,15 @@ MEM_STATIC size_t BIT_initCStream(BIT_CStream_t* bitC,
return 0;
}

FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
FORCE_INLINE_TEMPLATE size_t BIT_getLowerBits(BitContainerType 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)) && !defined(__ILP32__)
return _bzhi_u64(bitContainer, nbBits);
# else
DEBUG_STATIC_ASSERT(sizeof(bitContainer) == sizeof(U32));
return _bzhi_u32(bitContainer, nbBits);
# endif
#else
assert(nbBits < BIT_MASK_SIZE);
return bitContainer & BIT_mask[nbBits];
Expand Down

0 comments on commit a469e7c

Please sign in to comment.