-// See comment of _mm_popcnt_u64<>() few lines above for an explanation.
-template<typename T> inline unsigned __popcnt64(T) { return 0; } // Is never called
+#define POPCNT_INTRINSIC(x) (int)__popcnt64(x)
+
+#elif defined(__GNUC__) && defined(USE_POPCNT) // Gcc compiler
+
+inline bool cpu_has_popcnt() {
+
+ unsigned int eax, ebx, ecx, edx;
+ __cpuid(1, &eax, &ebx, &ecx, &edx);
+ return (ecx >> 23) & 1;
+}