[PATCH] Do not provide inlines for GCC build-in functions

Carlos O'Donell carlos@systemhalted.org
Fri May 18 04:12:00 GMT 2012


On Tue, May 15, 2012 at 3:36 PM, Andreas Jaeger <aj@suse.de> wrote:
>
> As mentioned previously
> (http://sourceware.org/ml/libc-alpha/2012-05/msg00106.html), GCC 3.4
> introduced builtin functions and thus the inlines are not needed at all.
>
> Patch was tested on Linux/x86-64 and I compared libc.so and libm.so and
> found no difference in the assembly.
>
> Looking at math/test-idouble I found a couple of places where GCC used
> now the builtins - instead of a function call like previously. So, GCC
> does a better job than the inlines.
>
> Ok to commit?
>
> Andreas
>
> 2012-05-15  Andreas Jaeger  <aj@suse.de>
>
>        * sysdeps/x86_64/fpu/bits/mathinline.h (lrintf): Make inline
>        function only available for GCCs before 3.4 since GCC 3.4
>        introduced a builtin.
>        (lrint): Likewise.
>        (llrintf): Likewise.
>        (llrint): Likewise.
>        (fmaxf): Likewise.
>        (fmax): Likewise.
>        (fminf): Likewise.
>        (fmin): Likewise.
>        (rint): Likewise.
>        (rintf): Likewise.
>        (nearbyint): Likewise.
>        (nearbyintf): Likewise.
>        (ceil): Likewise.
>        (ceilf): Likewise.
>        (floor): Likewise.
>        (floorf): Likewise.
>
> diff --git a/sysdeps/x86_64/fpu/bits/mathinline.h b/sysdeps/x86_64/fpu/bits/mathinline.h
> index 49a199b..310fcad 100644
> --- a/sysdeps/x86_64/fpu/bits/mathinline.h
> +++ b/sysdeps/x86_64/fpu/bits/mathinline.h
> @@ -68,7 +68,10 @@ __END_NAMESPACE_C99
>  #endif
>
>
> -#if __GNUC_PREREQ (2, 8) && !defined __NO_MATH_INLINES && defined __OPTIMIZE__
> +#if __GNUC_PREREQ (2, 8) && !__GNUC_PREREQ (3, 4) \
> +    && !defined __NO_MATH_INLINES && defined __OPTIMIZE__
> +/* GCC 3.4 introduced builtins for all functions below, so
> +   there's no need to define any of these inline functions.  */
>
>  # ifdef __USE_ISOC99
>  __BEGIN_NAMESPACE_C99

Looks good to me.

I double checked that GCC 3.3 doesn't have the builtins and GCC 3.4 does.

I find it a bit lame that we go from a math inline to a builtin behind
the users back, but this seems to be common practice, and I don't see
a better solution.

Cheers,
Carlos.



More information about the Libc-alpha mailing list