Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@neofob
Created October 18, 2013 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neofob/7043053 to your computer and use it in GitHub Desktop.
Save neofob/7043053 to your computer and use it in GitHub Desktop.
POPCNT

Use POPCNT instruction in C:

int result;
unsigned long long x;
...
result = __builtin_popcountll (x);

Compile the code with -mpopcnt option in gcc.

Check if your cpu has popcnt instruction:

grep --color popcnt /proc/cpuinfo

Reference: Stackoverflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment