How to enable support for the POPCNT instruction / intrinsic on my computer?
The first CPU to support the POPCNT
instruction was Intel's Nehalem. It looks like yours is of the Core line, which is older. Hasturkun's suggestion will work on your system, but will be implemented with multiple instructions instead of a single one.
If you want a portable solution rather than a GCC-specific one, check out Sean Eron Anderson's excellent Bit Twiddling Hacks page, which has highly optimized code for this.
Use __builtin_popcount()
instead, It isn't platform specific.
Your CPU does not support POPCNT
. (see https://en.wikipedia.org/wiki/SSE4)
But you can use this free and open source tool, to detect if it is supported:
https://github.com/mgorny/cpuid2cpuflags
It returns for Intel Core i7-3770 for example
CPU_FLAGS_X86: aes avx f16c mmx mmxext pclmul popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3