http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60788
--- Comment #1 from Allan Jensen <linux at carewolf dot com> --- Sorry. The optimization has nothing to do with it, it just causes the constant expressions used for testing to be evaluated at compile time. The real issue is that the lzcnt instruction does not return the number of leading zeroes, but the bitwidth minus the number of leading zeroes. So the mapping of _builtin_clz to lzcnt is simply naïve and incorrect.