https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81759
--- Comment #2 from Daniel Fruzynski <bugzi...@poradnik-webmastera.com> --- Looks that __builtin_ffs does not check if input value is nonzero at all. Assembler code for following code also has unnecessary instructions: [code] unsigned int test(unsigned int n) { if (n == 0) __builtin_unreachable(); return __builtin_ffs(n) - 1; } [/code]