Skip to content

Commit 85b08ce

Browse files
committed
Use compiler intrinsic instead of assembly for popcnt
This time, do not break compatibility with some AMD machines that have SSE3 and popcnt, but do not have SSE4.2. No functional change.
1 parent b9a88da commit 85b08ce

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ endif
285285

286286
### 3.9 popcnt
287287
ifeq ($(popcnt),yes)
288-
CXXFLAGS += -msse3 -DUSE_POPCNT
288+
CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT
289289
endif
290290

291291
### 3.10 pext

src/bitcount.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ inline int popcount<CNT_HW_POPCNT>(Bitboard b) {
9696

9797
#else
9898

99-
__asm__("popcnt %1, %0" : "=r" (b) : "r" (b));
100-
return b;
99+
return __builtin_popcountll(b);
101100

102101
#endif
103102
}

0 commit comments

Comments
 (0)