Just to show how SLOPPY, INCONSEQUENTIAL and INCOMPETENT GCC's developers are:
--- dontcare.c ---
int ispowerof2(unsigned __int128 argument) {
return __builtin_popcountll(argument) + __builtin_popcountll(argument >>
64) == 1;
}
--- EOF ---
GCC 13.3 gcc -march=haswell -O3
https://gcc.godbolt.org/z/PPzYsPzMc
ispowerof2(unsigned __int128):
popcnt rdi, rdi
popcnt rsi, rsi
add esi, edi
xor eax, eax
cmp esi, 1
sete al
ret
OOPS: what about Intel's CPU errata regarding the false dependency on POPCNTs
output?
See https://gcc.godbolt.org/z/jdjTc3EET for comparison!
FIX YOUR BUGS, KIDS!
Stefan