Counting bits in unsigned 64 bit using precomputation?

Revision en1, by -synx-, 2017-05-30 06:59:57

I know that counting bits using precomputation is the fastest way to go (over __builtin_popcount()).
For 32 bit integers we can do cnt[x>>16]+cnt[x&65535] by precomputing counts upto (1<<16).
How can we do it for 64 bit integers by precomputing upto (1<<22).

Tags popcount, bitwise

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English -synx- 2017-05-30 06:59:57 328 Initial revision (published)