Skip to content

Commit

Permalink
optimize popcnt
Browse files Browse the repository at this point in the history
no functional change
  • Loading branch information
xu-shawn committed Jan 20, 2025
1 parent 780aa75 commit 5575a63
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bitboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,11 @@ inline int popcount(Bitboard b) {

#ifndef USE_POPCNT

static constexpr auto Mask = 0xFFFF;
return PopCnt16[b & Mask] + PopCnt16[(b >> 16) & Mask] + PopCnt16[(b >> 32) & Mask]
+ PopCnt16[(b >> 48) & Mask];
std::uint16_t indicies[4];
std::memcpy(indicies, &b, sizeof(b));
return PopCnt16[indicies[0]] + PopCnt16[indicies[1]] + PopCnt16[indicies[2]]
+ PopCnt16[indicies[3]];


#elif defined(_MSC_VER)

Expand Down

0 comments on commit 5575a63

Please sign in to comment.