Closed
Description
Code:
int popcnt(int x) {
int cnt = 0;
while (x) {
cnt++;
x &= x - 1;
}
return cnt;
}
On x86-64 clang 16.0.0 as well as trunk (17.0.0 d7fa921) with -O -march=haswell
compiles to:
popcnt: # @popcnt
popcnt eax, edi
cmove eax, edi
ret
(Note the unnecessary cmove)
On clang 15.0.0 with the same options:
popcnt: # @popcnt
popcnt eax, edi
ret