From: Marco Costalba Date: Mon, 7 Apr 2014 14:02:24 +0000 (+0200) Subject: Add PEXT software implementation X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=2bfe61c33b99bd5ebb2e4616a6e8ac5790ff4c4f Add PEXT software implementation For development/debug purposes. No functional change. --- diff --git a/src/bitboard.cpp b/src/bitboard.cpp index bfacc412..27ba6574 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -79,6 +79,23 @@ namespace { } } + +/// Intel PEXT (parallel extraction) software implementation +Bitboard pext(Bitboard b, Bitboard mask) { + + Bitboard res = 0; + + for (Bitboard bb = 1; mask; bb += bb) + { + if (b & mask & -mask) + res |= bb; + + mask &= mask - 1; + } + return res; +} + + /// lsb()/msb() finds the least/most significant bit in a non-zero bitboard. /// pop_lsb() finds and clears the least significant bit in a non-zero bitboard. diff --git a/src/bitboard.h b/src/bitboard.h index 3ff0408a..140867fa 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -23,6 +23,8 @@ #include "types.h" +extern Bitboard pext(Bitboard b, Bitboard mask); + namespace Bitboards { void init();