soft-fp patch: Use __builtin_clz*
Joseph S. Myers
joseph@codesourcery.com
Thu Jan 5 12:30:00 GMT 2006
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
More information about the Libc-alpha
mailing list