X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.cpp;h=7d86884d12ee51caab40e70e1b14eac56b3f019c;hp=6f1569250a7fe6681c080733c86370fc32b46f0c;hb=c52da3b806b74ba5ab5249784d39da8fec3c7465;hpb=b599da01fa008e5f274a96c948f8346991bfd050 diff --git a/src/bitboard.cpp b/src/bitboard.cpp index 6f156925..7d86884d 100644 --- a/src/bitboard.cpp +++ b/src/bitboard.cpp @@ -366,6 +366,29 @@ Square pop_1st_bit(Bitboard* bb) { #endif +int bitScanReverse32(uint32_t b) +{ + int result = 0; + + if (b > 0xFFFF) { + b >>= 16; + result += 16; + } + if (b > 0xFF) { + b >>= 8; + result += 8; + } + if (b > 0xF) { + b >>= 4; + result += 4; + } + if (b > 0x3) { + b >>= 2; + result += 2; + } + return result + (b > 0) + (b > 1); +} + namespace { // All functions below are used to precompute various bitboards during