Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
Use tzcnt instead of bsf for better performance on ZEN/ZEN2.
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfpld committed Jun 18, 2020
1 parent b217307 commit 4b990cd
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/include/robin_hood.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,23 @@ static Counts& counts() {
#endif

// count leading/trailing bits
#ifdef _MSC_VER
#if ( ( defined __i386 || defined __x86_64__ ) && defined __BMI__ ) || defined _M_IX86 || 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
# if defined __AVX2__ || defined __BMI__
# define ROBIN_HOOD_COUNT_TRAILING_ZEROES(x) static_cast<int>(ROBIN_HOOD(CTZ)(x))
# else
# define ROBIN_HOOD_COUNT_TRAILING_ZEROES(x) ((x) ? static_cast<int>(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
Expand Down

0 comments on commit 4b990cd

Please sign in to comment.