This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Bit twiddling builtins
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Richard dot Earnshaw at arm dot com, Falk Hueffner <falk dot hueffner at student dot uni-tuebingen dot de>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Feb 2003 10:30:17 +0000
- Subject: Re: Bit twiddling builtins
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> 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.
This is really getting away from my original concern. Can someone making
use of the __builtin_clz builtin for ARM on gcc 3.2 get the same behaviour
now that we have the generic builtin of the same name without having to
change their source. If not, then I don't think we can rename the builtin
in this way.
R.