This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: soft-fp patch: Use __builtin_clz*
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Roland McGrath <roland at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 5 Jan 2006 12:30:42 +0000 (UTC)
- Subject: Re: soft-fp patch: Use __builtin_clz*
- References: <20060105080600.9FB0B180B7C@magilla.sf.frob.com>
On Thu, 5 Jan 2006, Roland McGrath wrote:
> > The soft-fp code has an inefficient generic default implementation of
> > __FP_CLZ. GCC 3.4 and greater provide __builtin_clz which can be used for
> > a better and simpler implementation. This patch makes soft-fp use these
> > built-in functions.
> >
> > In fact the only non-default definitions of __FP_CLZ are those in
> > sysdeps/i386/soft-fp/sfp-machine.h and
> > sysdeps/x86_64/soft-fp/sfp-machine.h. GCC knows how to expand
> > __builtin_clz/__builtin_clzl properly for both platforms, though on x86_64
> > it seems this support isn't there until GCC 4.0.
>
> From these two statements it's not clear whether __builtin_clz{,l,ll}
> actually work on all machines in GCC 3.4 or not. If they don't, then we
> can't use them unconditionally here.
They work on all machines in 3.4. If the target-specific expansion isn't
there then they call __clzsi2 and __clzdi2 which are defined in libgcc.
The definitions in libgcc in turn come from longlong.h, either
target-specific or a generic fallback. By "expand properly" I simply mean
using the proper instruction inline instead of calling __clz*.
--
Joseph S. Myers
joseph@codesourcery.com