This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, i386]: Use missing gcc math builtins


Quoting Ulrich Drepper <drepper@redhat.com>:

> > This patch enhances libc's mathinline.h header to use some missing
> builtins
> > (mainly rounding builtins) that were added during 4.0 timeframe.
> 
> But those builtins seem not to do much.  Just look at
> 
> #include <stdio.h>
> int
> main (void)
> {
>   double x = 4.5;
>   printf ("%g\n", __builtin_exp2l (x));
>   return 0;
> }
> 
> The __builtin_exp2l call is not expanded inline, it's expanded to a call
> to exp2l.  The definition in the libc header is complicated for a reason
> and I don't think gcc wants to hardcode that.

  It is OK this way. These builtins will be expanded to inlines only when
-ffast-math is added to compile flags. Otherwise, it will fall-back to function
call. Almost all x87 math builtins (including (float)->(int) conversions) are
enabled only with -ffast-math in gcc.

> I haven't looked at the remainder of the patch.  If there are some
> builtins which are indeed useful and there is a difference in the code
> generation, send a new patch.

  If -ffast-math is specified, all these builtins will be expanded to their
inlines. This patch mainly gets #defines from mathinline.h out of the way, when
correct version of gcc is used (patch is based on the same approach as some
earlier Jakub Jelinek's patch in this area).

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]