Returns the number of bits set; result is in the most significant byte
| 15 | namespace NBitMapPrivate { |
| 16 | // Returns the number of bits set; result is in the most significant byte |
| 17 | inline ui64 ByteSums(ui64 x) { |
| 18 | ui64 byteSums = x - ((x & 0xAAAAAAAAAAAAAAAAULL) >> 1); |
| 19 | |
| 20 | byteSums = (byteSums & 0x3333333333333333ULL) + ((byteSums >> 2) & 0x3333333333333333ULL); |
| 21 | byteSums = (byteSums + (byteSums >> 4)) & 0x0F0F0F0F0F0F0F0FULL; |
| 22 | |
| 23 | return byteSums * 0x0101010101010101ULL; |
| 24 | } |
| 25 | |
| 26 | // better than intrinsics without -mpopcnt |
| 27 | template <typename T> |