Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
pbsd
· 1y ago · 0 comments
Because the function is not quite correct. It should be
return n ? (1u + popcount(n & n - 1u)) : 0u;
which both Clang and GCC promptly optimize to a single popcnt.
Comments
[–]
1718627440
12mo ago
There should be testsuites, which are based on testing which compilation passes the compiler chose.