How many 1-bits in a word. Hardware calls it POPCNT. Kernighan walks only the set bits. This page runs both and demands they agree. live demo
Naive walk tests every bit. Kernighan does n &= n-1 once per set bit. Same answer or the page throws.
Population count is older than the x86 instruction. Kernighan’s trick is in The C Programming Language (2nd ed., 1988) as an exercise in bit craft. Intel POPCNT is SSE4.2 / ABM. This page does not claim the instruction. cited
Not run on the canonical compiler tonight. Bit-walk is representable as a bounded loop; that is a recommendation, not a measurement. AMBER