This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Bit twiddling builtins
On Tue, Feb 04, 2003 at 10:22:33AM +0000, Richard Earnshaw wrote:
> My personal opinion is that the "user-visible" function __builtin_clz(x)
> should be well-defined for all values of x, with x=0 resulting in the
> answer MODE_SIZE(x). That means that the *default* expansion of the
> builtin would have to be
>
> if (x == 0)
> (set (result) (const_int MODE_SIZE))
> else
> (set (result) (clz:M x))
I think this would be a mistake. I think more often than not the
context in which this gets used the programmer will already know
that the value is non-zero, but that won't necessarily be apparent
to the compiler.
I would be willing to attempt to recognize this pattern *in source*
and replace with just clz, as appropriate.
r~