[PATCH] Implement __abs?f2 functions in soft-fp

Roger Sayle roger@eyesopen.com
Fri Nov 1 18:26:00 GMT 2002


Hi Roland,
> If you are going to make gcc emit new calls, why not just have it call
> fabs/fabsf/fabsl directly?  Those are ISO C99 symbols, are they not?

Very true.  However, without support for __abs?f2 in soft-fp, glibc's
implementation of fabs/fabsf/fabsl is probably the same inefficient
compare against zero, and conditional negation sequence that GCC emits
inline.

Once there's an efficient __abs?f2, it can be used both by the library
fabs routines, and also inlined by the compiler.  This also avoids the
potential problem of GCC converting  "(x < 0)? -x : x" into a call to
"fabs" with -ffree-standing, i.e. without an ISO C library available.


I'll will freely admit that GCC is lacking in that it currently
doesn't have a cost model to allow it to realize that calling "fabs"
could be just as cheap (or perhaps cheaper) than using cmp/bnz/neg
when the latter would involve a libcall anyway.  My __abs?f2 patch
just works around this failing to both gcc's and glibc's benefit.

Roger
--



More information about the Libc-alpha mailing list