https://gcc.gnu.org/bugzilla/show_bug.cgi?id=72785
--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to dhowe...@redhat.com from comment #13) > Another possibility, at least for handling ilog2(), could be to provide > __builtin_ilog2(unsigned long x) as an alternative. > > Note that the kernel ilog2() has the property that the result is undefined > if x==0 (and will jump to ____ilog2_NaN() if x is constant 0). Ugh, no. Why not just x && (x & -x) == x ? __builtin_ctz (x) : -1 (or ctzl or ctzll depending on what the type is)?