

Popcount as an Example of Microbenchmarking in C [video] - teknotus
https://www.youtube.com/watch?v=opJvsJk1B68

======
dalke
It was a decent presentation. Popcount has a long history, going back to the
very first programming text book. (So says Knuth.) Someone interested in it
might also like the chapter in "Beautiful Code".

My own code does a lot of popcounts, of very wide (~1024 bit) values. A run
might take several hours, so for me a 1% performance boost is still a couple
of minutes of savings, and worth my development time to investigate.

On the other hand, I also use the POPCNT instruction if available, and fall
back to the nibble LUT version using the shuffle instruction if available,
before using the generic C versions. There are also some techniques that work
for very large sets of bits that aren't covered in this talk, which focused
only on 32 bit/word popcounts.

