-inline bool cpu_has_popcnt() {
-
- int CPUInfo[4] = {-1};
- __cpuid(CPUInfo, 0x00000001);
- return (CPUInfo[2] >> 23) & 1;
-}
-
-#define POPCNT_INTRINSIC(x) __popcnt64(x)
-#define BITSCAN_INTRINSIC(idx, x) _BitScanForward64(idx, x)
-
-#elif defined(__INTEL_COMPILER) && (defined(__x86_64) || defined(_M_X64)) // Intel compiler
-
-#include <nmmintrin.h>
-
-inline bool cpu_has_popcnt() {
-
- int CPUInfo[4] = {-1};
- __cpuid(CPUInfo, 0x00000001);
- return (CPUInfo[2] >> 23) & 1;
-}
-
-#define POPCNT_INTRINSIC(x) _mm_popcnt_u64(x)
-#define BITSCAN_INTRINSIC(idx, x) _BitScanForward64(idx, x)
-
-#else // Safe fallback for unsupported compilers
-
-inline bool cpu_has_popcnt() { return false; }
-
-#define POPCNT_INTRINSIC(x) sw_count_1s(x)
-#define BITSCAN_INTRINSIC(idx, x) sw_count_1s(x) // dummy
-
-#endif
+/// popcount() counts the number of nonzero bits in a bitboard
+template<BitCountType> inline int popcount(Bitboard);