For use in both the Fortran front-end and in libgfortran, it would be really 
nice to have __builtin_signbit() be type-generic. It makes sense from the C 
point of view too, because it’s the only built-in from the C99 type-generic 
floating-point macros that is not type-generic.

So far, I have built a compiler with the trivial change attached (marking the 
built-in type-generic in gcc/builtins.def) on x86_64-apple-darwin14, where I 
can confirm that the built-in is correctly expanded (without function call) on 
all floating-point types. Is there something more to do (apart from adjusting 
the documentation)?


Joseph, I’m CC’ing you because of a 7-year old comment in PR 36757, where you 
said:

> It's necessary to avoid the type-generic signbit expanding to call a library
> function that may not exist, but as all currently supported floating-point
> formats do have a sign bit specified in signbit_ro I believe the case
> of failing to expand inline can be made into an abort.

I can confirm that even in 2015, the only format which has (signbit_ro < 0) is 
real_internal_format, which I think doesn’t matter here. So: should I, in 
addition to the change in gcc/builtins.def, add some aborts() or sorry() in 
gcc/builtins.c if we can’t expand (which should never happen)?


Thanks in advance for your help,
FX


Attachment: signbit.diff
Description: Binary data

Reply via email to