On 08/17/2015 02:14 PM, FX wrote:
Attached patch makes __builtin_signbit type-generic in the middle-end (PR
36757).
Error message will be issued (from gcc/c-family/c-common.c) if argument is not
real (or too few, or too many).
gcc_assert() is used in expand_builtin_signbit() it cases that should be
unreachable (failure to expand inline).
Tested on x86_64-apple-darwin14, OK to commit?
FX
signbit.ChangeLog.txt
gcc/
2015-08-17 Francois-Xavier Coudert<fxcoud...@gcc.gnu.org>
PR middle-end/36757
* builtins.c (expand_builtin_signbit): Add asserts to make sure
we can expand BUILT_IN_SIGNBIT inline.
* builtins.def (BUILT_IN_SIGNBIT): Make type-generic.
* doc/extend.texi: Document the type-generic __builtin_signbit.
gcc/c-family/
2015-08-17 Francois-Xavier Coudert<fxcoud...@gcc.gnu.org>
PR middle-end/36757
* c-common.c (check_builtin_function_arguments): Add check
for BUILT_IN_SIGNBIT argument.
gcc/testsuite/
2015-08-17 Francois-Xavier Coudert<fxcoud...@gcc.gnu.org>
PR middle-end/36757
* gcc.dg/builtins-error.c: Add checks for __builtin_signbit.
* gcc.dg/tg-tests.h: Add checks for __builtin_signbit.
Index: gcc/testsuite/gcc.dg/tg-tests.h
===================================================================
--- gcc/testsuite/gcc.dg/tg-tests.h (revision 226894)
+++ gcc/testsuite/gcc.dg/tg-tests.h (working copy)
@@ -11,7 +11,7 @@ void __attribute__ ((__noinline__))
foo_1 (float f, double d, long double ld,
int res_unord, int res_isnan, int res_isinf,
int res_isinf_sign, int res_isfin, int res_isnorm,
- int classification)
+ int res_signbit, int classification)
{
if (__builtin_isunordered (f, 0) != res_unord)
__builtin_abort ();
@@ -80,6 +80,24 @@ foo_1 (float f, double d, long double ld
if (__builtin_finitel (ld) != res_isfin)
__builtin_abort ();
+ /* Sign bit of zeros and nans is not preserved in unsafe math mode. */
+#ifdef UNSAFE
+ if (!res_isnan && d != 0)
+#endif
+ {
+ __builtin_printf ("%d %d %g\n", __builtin_signbit (d), res_signbit, d);
Did you mean to keep this call to __builtin_printf?
OK with that removed, assuming it wasn't intentional.
jeff