https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785
--- Comment #16 from dhowells at redhat dot com <dhowells at redhat dot com> ---
I guess the following could be used:
int clz_ilog2(unsigned long x)
{
return __builtin_clz(x);
}
which compiles to:
0000000000000027 <clz_ilog2>:
27: 0f bd c7 bsr %edi,%eax
2a: 83 f0 1f xor $0x1f,%eax
2d: c3 retq
though the XOR is superfluous - for any valid input to ilog2(), I think the
output is always in the range 0-31.
