X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbitboard.h;h=6aa35874df7d3a244a8be9a919c81e09cc46105e;hp=4c7c948a8d28d0dfa9e8bc8c08f88471797b2b9d;hb=55bd27b8f08a151128d7065fa2819aa3e9605299;hpb=7c1f8dbde93267c7958a4de5e167a43e38c9e1e9 diff --git a/src/bitboard.h b/src/bitboard.h index 4c7c948a..6aa35874 100644 --- a/src/bitboard.h +++ b/src/bitboard.h @@ -247,6 +247,21 @@ FORCE_INLINE Square msb(Bitboard b) { return (Square) index; } +# elif defined(__arm__) + +FORCE_INLINE int lsb32(uint32_t v) { + __asm__("rbit %0, %1" : "=r"(v) : "r"(v)); + return __builtin_clz(v); +} + +FORCE_INLINE Square msb(Bitboard b) { + return (Square) (63 - __builtin_clzll(b)); +} + +FORCE_INLINE Square lsb(Bitboard b) { + return (Square) (uint32_t(b) ? lsb32(uint32_t(b)) : 32 + lsb32(uint32_t(b >> 32))); +} + # else FORCE_INLINE Square lsb(Bitboard b) { // Assembly code by Heinz van Saanen