From 85b08ce3adafbb1a70cd371cadb1e136e8879ebf Mon Sep 17 00:00:00 2001 From: lucasart Date: Thu, 3 Jul 2014 18:22:53 +0800 Subject: [PATCH] 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. --- src/Makefile | 2 +- src/bitcount.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 187e7b31..1e5a1658 100644 --- a/src/Makefile +++ b/src/Makefile @@ -285,7 +285,7 @@ endif ### 3.9 popcnt ifeq ($(popcnt),yes) - CXXFLAGS += -msse3 -DUSE_POPCNT + CXXFLAGS += -msse3 -mpopcnt -DUSE_POPCNT endif ### 3.10 pext diff --git a/src/bitcount.h b/src/bitcount.h index f84c51cb..9feed19f 100644 --- a/src/bitcount.h +++ b/src/bitcount.h @@ -96,8 +96,7 @@ inline int popcount(Bitboard b) { #else - __asm__("popcnt %1, %0" : "=r" (b) : "r" (b)); - return b; + return __builtin_popcountll(b); #endif } -- 2.39.2