]> git.sesse.net Git - stockfish/commitdiff
Use intrinsic in pop_1st_bit() under MSVC 64 bits
authorMarco Costalba <mcostalba@gmail.com>
Thu, 17 Mar 2011 12:47:15 +0000 (13:47 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 17 Mar 2011 13:29:09 +0000 (14:29 +0100)
Around 1% speedup when compiled with MSVC 64

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/bitboard.h
src/types.h

index 2451c13928e174208335433f8e1459948b504a56..9704839408e8ad7d9698222ecb2b664d0235cc53 100644 (file)
@@ -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.
 
 /// 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) );
   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<<s);
   return s;
   const Square s = first_1(*b);
   *b &= ~(1ULL<<s);
   return s;
index a5502c2f5df2f1e143494231aa53b971f68cfb21..623e51d9856570b713e69431d121378d0f1e2c61 100644 (file)
@@ -77,9 +77,8 @@ typedef unsigned __int64 uint64_t;
 #define IS_64BIT
 #endif
 
 #define IS_64BIT
 #endif
 
-// Automatic detection for use of bsfq asm-instruction under Windows.
-// Works only in 64-bit mode. Does not work with MSVC.
-#if defined(_WIN64) && defined(__INTEL_COMPILER)
+// Automatic detection for use of bsfq asm-instruction under Windows
+#if defined(_WIN64)
 #define USE_BSFQ
 #endif
 
 #define USE_BSFQ
 #endif