Skip to content

Commit

Permalink
Add PEXT software implementation
Browse files Browse the repository at this point in the history
For development/debug purposes.

No functional change.
  • Loading branch information
mcostalba committed Apr 12, 2014
1 parent 2f92e3b commit 2bfe61c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/bitboard.cpp
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions src/bitboard.h
Expand Up @@ -23,6 +23,8 @@

#include "types.h"

extern Bitboard pext(Bitboard b, Bitboard mask);

namespace Bitboards {

void init();
Expand Down

0 comments on commit 2bfe61c

Please sign in to comment.