Use tzcnt instead of bsf.

This commit is contained in:
Bartosz Taudul 2020-06-16 18:19:05 +02:00
parent 7a6141389c
commit 47dfddedfd

View File

@ -128,7 +128,23 @@ static Counts& counts() {
#endif
// count leading/trailing bits
#ifdef _MSC_VER
#if defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64
# ifdef _MSC_VER
# include <intrin.h>
# else
# include <x86intrin.h>
# endif
# if ROBIN_HOOD(BITNESS) == 32
# define ROBIN_HOOD_PRIVATE_DEFINITION_CTZ() _tzcnt_u32
# else
# define ROBIN_HOOD_PRIVATE_DEFINITION_CTZ() _tzcnt_u64
# endif
# ifdef __AVX2__
# define ROBIN_HOOD_COUNT_TRAILING_ZEROES(x) ROBIN_HOOD(CTZ)(x)
# else
# define ROBIN_HOOD_COUNT_TRAILING_ZEROES(x) ((x) ? ROBIN_HOOD(CTZ)(x) : ROBIN_HOOD(BITNESS))
# endif
#elif defined _MSC_VER
# if ROBIN_HOOD(BITNESS) == 32
# define ROBIN_HOOD_PRIVATE_DEFINITION_BITSCANFORWARD() _BitScanForward
# else