-inline bool cpu_has_popcnt() {
-
- unsigned int eax, ebx, ecx, edx;
- __cpuid(1, &eax, &ebx, &ecx, &edx);
- return (ecx >> 23) & 1;
-}
-
-#define POPCNT_INTRINSIC(x) ({ \
- unsigned long __ret; \
- __asm__("popcnt %1, %0" : "=r" (__ret) : "r" (x)); \
- __ret; })
-
-#else // Safe fallback for unsupported compilers or when USE_POPCNT is disabled
-
-inline bool cpu_has_popcnt() { return false; }
-
-#define POPCNT_INTRINSIC(x) 0
-
-#endif // cpu_has_popcnt() and POPCNT_INTRINSIC() definitions
-
-
-/// Software implementation of bit count functions
-
-#if defined(IS_64BIT)
-
-inline int count_1s(Bitboard b) {
- b -= ((b>>1) & 0x5555555555555555ULL);
- b = ((b>>2) & 0x3333333333333333ULL) + (b & 0x3333333333333333ULL);
- b = ((b>>4) + b) & 0x0F0F0F0F0F0F0F0FULL;
- b *= 0x0101010101010101ULL;
- return int(b >> 56);
-}
-
-inline int count_1s_max_15(Bitboard b) {
- b -= (b>>1) & 0x5555555555555555ULL;
- b = ((b>>2) & 0x3333333333333333ULL) + (b & 0x3333333333333333ULL);
- b *= 0x1111111111111111ULL;
- return int(b >> 60);
-}
-
-#else // if !defined(IS_64BIT)
-
-inline int count_1s(Bitboard b) {