]> git.sesse.net Git - stockfish/commitdiff
Add PEXT software implementation
authorMarco Costalba <mcostalba@gmail.com>
Mon, 7 Apr 2014 14:02:24 +0000 (16:02 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Sat, 12 Apr 2014 06:55:30 +0000 (08:55 +0200)
For development/debug purposes.

No functional change.

src/bitboard.cpp
src/bitboard.h

index bfacc4121a0312b2d2461239008344c940c3857f..27ba65747d6faf05cf4cdb3e2442aa0f0b7cdbe6 100644 (file)
@@ -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.
 
 /// 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.
 
index 3ff0408a61b16faab014965ed063af2c85124a0c..140867fa94a466272d55be020451b0eb8b012f77 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "types.h"
 
 
 #include "types.h"
 
+extern Bitboard pext(Bitboard b, Bitboard mask);
+
 namespace Bitboards {
 
 void init();
 namespace Bitboards {
 
 void init();