OSDN Git Service

* doc/extend.texi (Other Builtins): Add decimal float variants
authorjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Apr 2007 22:10:28 +0000 (22:10 +0000)
committerjanis <janis@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Apr 2007 22:10:28 +0000 (22:10 +0000)
of signbit.
* builtins.def: Ditto.
* builtins.c (expand_builtin): Ditto.
testsuite/
* gcc.dg/dfp/signbit-1.c
* gcc.dg/dfp/signbit-2.c
M    gcc/doc/extend.texi
M    gcc/builtins.c
M    gcc/ChangeLog
A    gcc/testsuite/gcc.dg/dfp/signbit-2.c
A    gcc/testsuite/gcc.dg/dfp/signbit-1.c
M    gcc/testsuite/ChangeLog
M    gcc/builtins.def

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123528 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/doc/extend.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/signbit-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/signbit-2.c [new file with mode: 0644]

index bef1dfb..906f1c3 100644 (file)
@@ -1,3 +1,10 @@
+2007-04-05  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.
+
 2007-04-05  Uros Bizjak  <ubizjak@gmail.com>
            H.J. Lu  <hongjiu.lu@intel.com>
 
index 989b8d7..498aea6 100644 (file)
@@ -5553,7 +5553,8 @@ expand_builtin_adjust_trampoline (tree exp)
   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.  */
@@ -6490,6 +6491,9 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
       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 ebcbe11..e0652c8 100644 (file)
@@ -381,6 +381,9 @@ DEF_C99_BUILTIN        (BUILT_IN_SCALBNL, "scalbnl", BT_FN_LONGDOUBLE_LONGDOUBLE
 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 ccdc995..ce63202 100644 (file)
@@ -5609,6 +5609,9 @@ should be called and the @var{flag} argument passed to it.
 @findex signbit
 @findex signbitf
 @findex signbitl
+@findex signbitd32
+@findex signbitd64
+@findex signbitd128
 @findex significand
 @findex significandf
 @findex significandl
@@ -5713,6 +5716,7 @@ Outside strict ISO C mode (@option{-ansi}, @option{-std=c89} or
 @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 28316c2..45181d0 100644 (file)
@@ -1,13 +1,18 @@
-2007-04-05  Paul Thomas  <pault@gcc.gnu.org>\r
-\r
-       PR fortran/31483\r
-       * gfortran.dg/altreturn_5.f90: New test.\r
-
-2007-04-05  Paul Thomas  <pault@gcc.gnu.org>\r
-\r
-       PR fortran/31292\r
-       * gfortran.dg/contained_module_proc_1.f90: New test.\r
-\r
+2007-04-05  Janis Johnson  <janis187@us.ibm.com>
+
+       * gcc.dg/dfp/signbit-1.c
+       * gcc.dg/dfp/signbit-2.c
+
+2007-04-05  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/31483
+       * gfortran.dg/altreturn_5.f90: New test.
+
+2007-04-05  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/31292
+       * gfortran.dg/contained_module_proc_1.f90: New test.
+
 2007-04-04  Stuart Hastings  <stuart@apple.com>
 
        PR 31281
diff --git a/gcc/testsuite/gcc.dg/dfp/signbit-1.c b/gcc/testsuite/gcc.dg/dfp/signbit-1.c
new file mode 100644 (file)
index 0000000..cde28f9
--- /dev/null
@@ -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;
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/signbit-2.c b/gcc/testsuite/gcc.dg/dfp/signbit-2.c
new file mode 100644 (file)
index 0000000..6f9a227
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-options "-O0 -std=gnu99" } */
+
+/* Check that the compiler uses builtins for signbit; if not the link
+   will fail because library functions are in libm.  */
+
+extern void abort (void);
+
+volatile _Decimal32 sd = 2.3df;
+volatile _Decimal64 dd = -4.5dd;
+volatile _Decimal128 tf = 5.3dl;
+volatile float f = 1.2f;
+volatile double d = -7.8;
+volatile long double ld = 3.4L;
+
+extern int signbitf (float);
+extern int signbit (double);
+extern int signbitl (long double);
+extern int signbitd32 (_Decimal32);
+extern int signbitd64 (_Decimal64);
+extern int signbitd128 (_Decimal128);
+
+int
+main ()
+{
+  if (signbitf (f) != 0) abort ();
+  if (signbit (d) == 0) abort ();
+  if (signbitl (ld) != 0) abort ();
+  if (signbitd32 (sd) != 0) abort ();
+  if (signbitd64 (dd) == 0) abort ();
+  if (signbitd128 (tf) != 0) abort ();
+
+  return 0;
+}