Janis Johnson - [PATCH] decimal float versions of __builtin_signbit (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC 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]

This patch adds __builtin_signbit for the three decimal floating types. Those types record the position of the signbit in the same way as other floating types, so no change is needed to expand_builtin_signbit.

Bootstrapped and regression tested on powerpc64-linux; OK for mainline?

2007-02-23 Janis Johnson janis187@us.ibm.com

* doc/extend.texi (Other Builtins): Add decimal float variants
of signbit.
* builtins.def: Ditto.
* builtins.c (expand_builtin): Ditto.

gcc/testsuite/ * gcc.dg/dfp/signbit-1.c * gcc.dg/dfp/signbit-2.c

Index: gcc/doc/extend.texi

--- gcc/doc/extend.texi (revision 122239) +++ gcc/doc/extend.texi (working copy) @@ -5537,6 +5537,9 @@ @findex signbit @findex signbitf @findex signbitl +@findex signbitd32 +@findex signbitd64 +@findex signbitd128 @findex significand @findex significandf @findex significandl @@ -5641,6 +5644,7 @@ @code{mempcpy}, @code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked}, @code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb}, @code{signbit}, @code{signbitf}, @code{signbitl}, +@code{signbitd32}, @code{signbitd64}, @code{signbitd128}, @code{significandf}, @code{significandl}, @code{significand}, @code{sincosf}, @code{sincosl}, @code{sincos}, @code{stpcpy}, @code{stpncpy}, @code{strcasecmp}, @code{strdup}, @code{strfmon}, Index: gcc/builtins.def

--- gcc/builtins.def (revision 122239) +++ gcc/builtins.def (working copy) @@ -381,6 +381,9 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBIT, "signbit", BT_FN_INT_DOUBLE, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBITF, "signbitf", BT_FN_INT_FLOAT, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBITL, "signbitl", BT_FN_INT_LONGDOUBLE, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBITD32, "signbitd32", BT_FN_INT_DFLOAT32, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBITD64, "signbitd64", BT_FN_INT_DFLOAT64, ATTR_CONST_NOTHROW_LIST) +DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNBITD128, "signbitd128", BT_FN_INT_DFLOAT128, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNIFICAND, "significand", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO) DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNIFICANDF, "significandf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO) DEF_EXT_LIB_BUILTIN (BUILT_IN_SIGNIFICANDL, "significandl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO) Index: gcc/builtins.c

--- gcc/builtins.c (revision 122239) +++ gcc/builtins.c (working copy) @@ -5494,7 +5494,8 @@ return tramp; } -/* Expand a call to the built-in signbit, signbitf or signbitl function. +/* Expand a call to the built-in signbit, signbitf, signbitl, signbitd32, + signbitd64, or signbitd128 function. Return NULL_RTX if a normal call should be emitted rather than expanding the function in-line. EXP is the expression that is a call to the builtin function; if convenient, the result should be placed in TARGET. */ @@ -6412,6 +6413,9 @@ break; CASE_FLT_FN (BUILT_IN_SIGNBIT): + case BUILT_IN_SIGNBITD32: + case BUILT_IN_SIGNBITD64: + case BUILT_IN_SIGNBITD128: target = expand_builtin_signbit (exp, target); if (target) return target; Index: gcc/testsuite/gcc.dg/dfp/signbit-1.c

--- gcc/testsuite/gcc.dg/dfp/signbit-1.c (revision 0) +++ gcc/testsuite/gcc.dg/dfp/signbit-1.c (revision 0) @@ -0,0 +1,50 @@ +/* { dg-options "-O0 -std=gnu99" } / + +/ Decimal float versions of __builtin_signbit. */ + +extern void abort (void); +int failures; + +#ifdef DBG +extern int printf (const char , ...); +#define FAILURE { printf ("failed at line %d\n", LINE); failures++; } +#else +#define FAILURE abort (); +#endif + +#define CHECK32(D,I)
+ if ((__builtin_signbitd32 (D) != 0) != I) FAILURE + +#define CHECK64(D,I)
+ if ((__builtin_signbitd64 (D) != 0) != I) FAILURE + +#define CHECK128(D,I)
+ if ((__builtin_signbitd128 (D) != 0) != I) FAILURE + +/
Prevent the compiler from folding the calls at compile time. */ +volatile _Decimal32 sd; +volatile _Decimal64 dd; +volatile _Decimal128 td; + +int +main () +{ + sd = 1.9df; CHECK32 (sd, 0) + sd = -5.3df; CHECK32 (sd, 1) + sd = 0.0df; CHECK32 (sd, 0) + sd = -0.0df; CHECK32 (sd, 1) + + dd = 1.9dd; CHECK64 (dd, 0) + dd = -5.3dd; CHECK64 (dd, 1) + dd = 0.0dd; CHECK64 (dd, 0) + dd = -0.0dd; CHECK64 (dd, 1) + + td = 1.9dl; CHECK128 (td, 0) + td = -5.3dl; CHECK128 (td, 1) + td = 0.0dl; CHECK128 (td, 0) + td = -0.0dl; CHECK128 (td, 1) + + if (failures != 0) + abort (); + return 0; +} Index: gcc/testsuite/gcc.dg/dfp/signbit-2.c

--- gcc/testsuite/gcc.dg/dfp/signbit-2.c (revision 0) +++ gcc/testsuite/gcc.dg/dfp/signbit-2.c (revision 0) @@ -0,0 +1,33 @@ +/* { dg-options "-O0 -std=gnu99" } / + +/ Check that the compiler uses builtins for signbit; if not the link


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