This patch addresses PR middle-end/32668, which is a problem with
type-generic builtins. Because they are implemented with variadic
prototypes, these builtins promote float to double which can either cause
pessimization and/or incorrect code generated from the middle-end.
My solution (suggested by Joseph) was to create a new internal-only
attribute to mark variadic builtins as "type generic" which notifies GCC
not to do the default C promotions for these calls. This was discussed in
this thread: http://gcc.gnu.org/ml/gcc/2007-07/msg00221.html
I didn't document the builtin because the only other internal-only builtin
"no vops" wasn't document either AFAICT. I could be convinced to document
"type generic" if necessary, but I don't want to confuse users who can't
use it anyway.
Although we normally test patches in isolation, this patch needs my other
recent work to really get exercised. So I combined this patch with the
other stuff I have submitted to make use of these type-generic builtins.
It was bootstrapped along with these patches (with some minor conflicts
resolved in builtins.def):
isinf:
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01103.html
isfinite:
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01211.html
isnormal:
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01292.html
Check/test subnormals:
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg00063.html
Add more testcases (& temporarily fix solaris fixincludes):
http://gcc.gnu.org/ml/gcc-patches/2007-07/msg00583.html
Remove solaris fixincludes hacks, rely only on builtins:
http://gcc.gnu.org/ml/gcc-patches/2007-06/msg01478.html
Bootstrap and regtest passed. This can go in either before or after any
of the above patches. It's only when they're all combined that you notice
the need for it in the isnormal builtin which gets more rigorously checked
through my extra testcases.
Okay for mainline?
2007-07-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
PR middle-end/32668
* builtin-attrs.def (ATTR_TYPEGENERIC,
ATTR_CONST_NOTHROW_TYPEGENERIC): New.
* builtins.def (BUILT_IN_ISINF, BUILT_IN_ISNAN,
BUILT_IN_ISGREATER, BUILT_IN_ISGREATEREQUAL, BUILT_IN_ISLESS,
BUILT_IN_ISLESSEQUAL, BUILT_IN_ISLESSGREATER,
BUILT_IN_ISUNORDERED): Use ATTR_CONST_NOTHROW_TYPEGENERIC.
* c-common.c (handle_type_generic_attribute): New.
(c_common_attribute_table): Add "type generic".
* c-typeck.c (convert_arguments): Handle "type generic" functions.