From: Marco Costalba Date: Thu, 17 Mar 2011 12:47:15 +0000 (+0100) Subject: Use intrinsic in pop_1st_bit() under MSVC 64 bits X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=5ea08e79c4e510b65b3e18c9ab09919132976eec;ds=sidebyside Use intrinsic in pop_1st_bit() under MSVC 64 bits Around 1% speedup when compiled with MSVC 64 No functional change. Signed-off-by: Marco Costalba --- diff --git a/src/bitboard.h b/src/bitboard.h index 2451c139..97048394 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -257,15 +257,25 @@ inline bool squares_aligned(Square s1, Square s2, Square s3) { /// pop_1st_bit() finds and clears the least significant nonzero bit in a /// nonzero bitboard. -#if defined(USE_BSFQ) // Assembly code by Heinz van Saanen +#if defined(USE_BSFQ) -inline Square first_1(Bitboard b) { +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) + +FORCE_INLINE Square first_1(Bitboard b) { + unsigned long index; + _BitScanForward64(&index, b); + return (Square) index; +} +#else + +FORCE_INLINE Square first_1(Bitboard b) { // Assembly code by Heinz van Saanen Bitboard dummy; __asm__("bsfq %1, %0": "=r"(dummy): "rm"(b) ); - return (Square)(dummy); + return (Square) dummy; } +#endif -inline Square pop_1st_bit(Bitboard* b) { +FORCE_INLINE Square pop_1st_bit(Bitboard* b) { const Square s = first_1(*b); *b &= ~(1ULL<