builtins.def: (_Float<N> and _Float<N>X BUILT_IN_CEIL): Add _Float<N> and _Float...
authorMichael Meissner <meissner@linux.vnet.ibm.com>
Thu, 28 Dec 2017 21:19:12 +0000 (21:19 +0000)
committerMichael Meissner <meissner@gcc.gnu.org>
Thu, 28 Dec 2017 21:19:12 +0000 (21:19 +0000)
[gcc]
2017-12-28  Michael Meissner  <meissner@linux.vnet.ibm.com>

* builtins.def: (_Float<N> and _Float<N>X BUILT_IN_CEIL): Add
_Float<N> and _Float<N>X variants for rounding built-in
functions.
(_Float<N> and _Float<N>X BUILT_IN_FLOOR): Likewise.
(_Float<N> and _Float<N>X BUILT_IN_NEARBYINT): Likewise.
(_Float<N> and _Float<N>X BUILT_IN_RINT): Likewise.
(_Float<N> and _Float<N>X BUILT_IN_ROUND): Likewise.
(_Float<N> and _Float<N>X BUILT_IN_TRUNC): Likewise.
* builtins.c (mathfn_built_in_2): Likewise.
* internal-fn.def (CEIL): Likewise.
(FLOOR): Likewise.
(NEARBYINT): Likewise.
(RINT): Likewise.
(ROUND): Likewise.
(TRUNC): Likewise.
* convert.c (convert_to_integer_1): Likewise.
* fold-const.c (tree_call_nonnegative_warnv_p): Likewise.
(integer_valued_real_call_p): Likewise.
* fold-const-call.c (fold_const_call_ss): Likewise.
* gencfn-macros.c (print_case_cfn): Change CFN and operator
printers to take a const char * suffix instead of a bool.
(print_define_operator_list): Likewise.
(fltall_suffixes): New list of suffixes, that include the
traditional suffixes as well as all of the _Float<N> and
_Float<N>X suffixes.
(main): For _Float<N> and _Float<N>X functions, emit both
<name>_FN and <name>_ALL variants.  The <macro>_FN variant only
has the _Float<N> and _Float<N>X case names or operators.  The
<name>_ALL variant has both the traditional and the
_Float<N>/_Float<N>X case names or operators.
* match.pd (COPYSIGN optimizations): Provide optimizations for
_Float<N> and _Float<N>X types where possible.
(MIN/MAX optimizations): Likewise.
(sqrt optimizations): Likewise.
(rounding optimizations): Likewise.

[gcc/c]
2017-12-28  Michael Meissner  <meissner@linux.vnet.ibm.com>

* c-decl.c (header_for_builtin_fn): Add integer rounding _Float<N>
and _Float<N>X built-in functions.

From-SVN: r256026

gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/c/ChangeLog
gcc/c/c-decl.c
gcc/convert.c
gcc/fold-const-call.c
gcc/fold-const.c
gcc/gencfn-macros.c
gcc/internal-fn.def
gcc/match.pd

index ad395ef7724f905132f11b4f6fd6c77b0bf98507..c3a0ef322d8970afbfb01096b5101b03a993bc4e 100644 (file)
@@ -1,3 +1,41 @@
+2017-12-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
+
+       * builtins.def: (_Float<N> and _Float<N>X BUILT_IN_CEIL): Add
+       _Float<N> and _Float<N>X variants for rounding built-in
+       functions.
+       (_Float<N> and _Float<N>X BUILT_IN_FLOOR): Likewise.
+       (_Float<N> and _Float<N>X BUILT_IN_NEARBYINT): Likewise.
+       (_Float<N> and _Float<N>X BUILT_IN_RINT): Likewise.
+       (_Float<N> and _Float<N>X BUILT_IN_ROUND): Likewise.
+       (_Float<N> and _Float<N>X BUILT_IN_TRUNC): Likewise.
+       * builtins.c (mathfn_built_in_2): Likewise.
+       * internal-fn.def (CEIL): Likewise.
+       (FLOOR): Likewise.
+       (NEARBYINT): Likewise.
+       (RINT): Likewise.
+       (ROUND): Likewise.
+       (TRUNC): Likewise.
+       * convert.c (convert_to_integer_1): Likewise.
+       * fold-const.c (tree_call_nonnegative_warnv_p): Likewise.
+       (integer_valued_real_call_p): Likewise.
+       * fold-const-call.c (fold_const_call_ss): Likewise.
+       * gencfn-macros.c (print_case_cfn): Change CFN and operator
+       printers to take a const char * suffix instead of a bool.
+       (print_define_operator_list): Likewise.
+       (fltall_suffixes): New list of suffixes, that include the
+       traditional suffixes as well as all of the _Float<N> and
+       _Float<N>X suffixes.
+       (main): For _Float<N> and _Float<N>X functions, emit both
+       <name>_FN and <name>_ALL variants.  The <macro>_FN variant only
+       has the _Float<N> and _Float<N>X case names or operators.  The
+       <name>_ALL variant has both the traditional and the
+       _Float<N>/_Float<N>X case names or operators.
+       * match.pd (COPYSIGN optimizations): Provide optimizations for
+       _Float<N> and _Float<N>X types where possible.
+       (MIN/MAX optimizations): Likewise.
+       (sqrt optimizations): Likewise.
+       (rounding optimizations): Likewise.
+
 2017-12-28  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * config/powerpcspe/powerpcspe.md (ieee_128bit_negative_zero): Use
index 753809f2357009a062e5bc7e742d5f2380d9c3d8..98eb804a2753a26c1e8f50f1745a2f665870e346 100644 (file)
@@ -1877,7 +1877,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     CASE_MATHFN (ATAN2)
     CASE_MATHFN (ATANH)
     CASE_MATHFN (CBRT)
-    CASE_MATHFN (CEIL)
+    CASE_MATHFN_FLOATN (CEIL)
     CASE_MATHFN (CEXPI)
     CASE_MATHFN_FLOATN (COPYSIGN)
     CASE_MATHFN (COS)
@@ -1891,7 +1891,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     CASE_MATHFN (EXPM1)
     CASE_MATHFN (FABS)
     CASE_MATHFN (FDIM)
-    CASE_MATHFN (FLOOR)
+    CASE_MATHFN_FLOATN (FLOOR)
     CASE_MATHFN_FLOATN (FMA)
     CASE_MATHFN_FLOATN (FMAX)
     CASE_MATHFN_FLOATN (FMIN)
@@ -1930,7 +1930,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     CASE_MATHFN (MODF)
     CASE_MATHFN (NAN)
     CASE_MATHFN (NANS)
-    CASE_MATHFN (NEARBYINT)
+    CASE_MATHFN_FLOATN (NEARBYINT)
     CASE_MATHFN (NEXTAFTER)
     CASE_MATHFN (NEXTTOWARD)
     CASE_MATHFN (POW)
@@ -1938,8 +1938,8 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     CASE_MATHFN (POW10)
     CASE_MATHFN (REMAINDER)
     CASE_MATHFN (REMQUO)
-    CASE_MATHFN (RINT)
-    CASE_MATHFN (ROUND)
+    CASE_MATHFN_FLOATN (RINT)
+    CASE_MATHFN_FLOATN (ROUND)
     CASE_MATHFN (SCALB)
     CASE_MATHFN (SCALBLN)
     CASE_MATHFN (SCALBN)
@@ -1952,7 +1952,7 @@ mathfn_built_in_2 (tree type, combined_fn fn)
     CASE_MATHFN (TAN)
     CASE_MATHFN (TANH)
     CASE_MATHFN (TGAMMA)
-    CASE_MATHFN (TRUNC)
+    CASE_MATHFN_FLOATN (TRUNC)
     CASE_MATHFN (Y0)
     CASE_MATHFN (Y1)
     CASE_MATHFN (YN)
index 228102199251b68906645775ac9c8fe69eb87150..671097ea29cb804c3e62ac40f1af742229959223 100644 (file)
@@ -330,6 +330,9 @@ DEF_C99_BUILTIN        (BUILT_IN_CBRTL, "cbrtl", BT_FN_LONGDOUBLE_LONGDOUBLE, AT
 DEF_LIB_BUILTIN        (BUILT_IN_CEIL, "ceil", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_CEILF, "ceilf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_CEILL, "ceill", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define CEIL_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_CEIL, "ceil", CEIL_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef CEIL_TYPE
 DEF_C99_BUILTIN        (BUILT_IN_COPYSIGN, "copysign", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_COPYSIGNF, "copysignf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_COPYSIGNL, "copysignl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
@@ -389,6 +392,9 @@ DEF_C99_BUILTIN        (BUILT_IN_FEUPDATEENV, "feupdateenv", BT_FN_INT_CONST_FEN
 DEF_LIB_BUILTIN        (BUILT_IN_FLOOR, "floor", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FLOORF, "floorf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_C90RES_BUILTIN (BUILT_IN_FLOORL, "floorl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define FLOOR_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_FLOOR, "floor", FLOOR_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef FLOOR_TYPE
 DEF_C99_BUILTIN        (BUILT_IN_FMA, "fma", BT_FN_DOUBLE_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_C99_BUILTIN        (BUILT_IN_FMAF, "fmaf", BT_FN_FLOAT_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
 DEF_C99_BUILTIN        (BUILT_IN_FMAL, "fmal", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
@@ -526,6 +532,9 @@ DEF_GCC_FLOATN_NX_BUILTINS (BUILT_IN_NANS, "nans", NAN_TYPE, ATTR_CONST_NOTHROW_
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINT, "nearbyint", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINTF, "nearbyintf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_NEARBYINTL, "nearbyintl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define NEARBYINT_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_NEARBYINT, "nearbyint", NEARBYINT_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef NEARBYINT_TYPE
 DEF_C99_BUILTIN        (BUILT_IN_NEXTAFTER, "nextafter", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_NEXTAFTERF, "nextafterf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_NEXTAFTERL, "nextafterl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_ERRNO)
@@ -550,9 +559,15 @@ DEF_C99_BUILTIN        (BUILT_IN_REMQUOL, "remquol", BT_FN_LONGDOUBLE_LONGDOUBLE
 DEF_C99_BUILTIN        (BUILT_IN_RINT, "rint", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING)
 DEF_C99_BUILTIN        (BUILT_IN_RINTF, "rintf", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING)
 DEF_C99_BUILTIN        (BUILT_IN_RINTL, "rintl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING)
+#define RINT_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_RINT, "rint", RINT_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef RINT_TYPE
 DEF_C99_BUILTIN        (BUILT_IN_ROUND, "round", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDF, "roundf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ROUNDL, "roundl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define ROUND_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_ROUND, "round", ROUND_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef ROUND_TYPE
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_SCALB, "scalb", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_SCALBF, "scalbf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_SCALBL, "scalbl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
@@ -598,6 +613,9 @@ DEF_C99_BUILTIN        (BUILT_IN_TGAMMAL, "tgammal", BT_FN_LONGDOUBLE_LONGDOUBLE
 DEF_C99_BUILTIN        (BUILT_IN_TRUNC, "trunc", BT_FN_DOUBLE_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_TRUNCF, "truncf", BT_FN_FLOAT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_TRUNCL, "truncl", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#define TRUNC_TYPE(F) BT_FN_##F##_##F
+DEF_EXT_LIB_FLOATN_NX_BUILTINS (BUILT_IN_TRUNC, "trunc", TRUNC_TYPE, ATTR_CONST_NOTHROW_LEAF_LIST)
+#undef TRUNC_TYPE
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_Y0, "y0", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_Y0F, "y0f", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_Y0L, "y0l", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
index 504205dc7de0316f0b5d2c33308f28086de9ebbd..f76110a62b1c6aecdc6723df07dc1ebd5f07bb20 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-28  Michael Meissner  <meissner@linux.vnet.ibm.com>
+
+       * c-decl.c (header_for_builtin_fn): Add integer rounding _Float<N>
+       and _Float<N>X built-in functions.
+
 2017-12-22  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/83550
index 846098ea8367c1f9c31c9ef70578ba8d6670f19d..d3294c390721c73bb53b40f873bd875e22e06177 100644 (file)
@@ -3168,6 +3168,7 @@ header_for_builtin_fn (enum built_in_function fcode)
     CASE_FLT_FN (BUILT_IN_ATAN2):
     CASE_FLT_FN (BUILT_IN_CBRT):
     CASE_FLT_FN (BUILT_IN_CEIL):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
     CASE_FLT_FN (BUILT_IN_COPYSIGN):
     CASE_FLT_FN_FLOATN_NX (BUILT_IN_COPYSIGN):
     CASE_FLT_FN (BUILT_IN_COS):
@@ -3181,6 +3182,7 @@ header_for_builtin_fn (enum built_in_function fcode)
     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FABS):
     CASE_FLT_FN (BUILT_IN_FDIM):
     CASE_FLT_FN (BUILT_IN_FLOOR):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
     CASE_FLT_FN (BUILT_IN_FMA):
     CASE_FLT_FN_FLOATN_NX (BUILT_IN_FMA):
     CASE_FLT_FN (BUILT_IN_FMAX):
@@ -3205,13 +3207,16 @@ header_for_builtin_fn (enum built_in_function fcode)
     CASE_FLT_FN (BUILT_IN_MODF):
     CASE_FLT_FN (BUILT_IN_NAN):
     CASE_FLT_FN (BUILT_IN_NEARBYINT):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
     CASE_FLT_FN (BUILT_IN_NEXTAFTER):
     CASE_FLT_FN (BUILT_IN_NEXTTOWARD):
     CASE_FLT_FN (BUILT_IN_POW):
     CASE_FLT_FN (BUILT_IN_REMAINDER):
     CASE_FLT_FN (BUILT_IN_REMQUO):
     CASE_FLT_FN (BUILT_IN_RINT):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
     CASE_FLT_FN (BUILT_IN_ROUND):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
     CASE_FLT_FN (BUILT_IN_SCALBLN):
     CASE_FLT_FN (BUILT_IN_SCALBN):
     CASE_FLT_FN (BUILT_IN_SIN):
@@ -3223,6 +3228,7 @@ header_for_builtin_fn (enum built_in_function fcode)
     CASE_FLT_FN (BUILT_IN_TANH):
     CASE_FLT_FN (BUILT_IN_TGAMMA):
     CASE_FLT_FN (BUILT_IN_TRUNC):
+    CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
     case BUILT_IN_ISINF:
     case BUILT_IN_ISNAN:
       return "<math.h>";
index 25aa5adf88026267974e26f71f094fca10ca0f2c..1607bededbc519bccfaf11ac4687cb280a095082 100644 (file)
@@ -554,6 +554,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
       switch (fcode)
         {
        CASE_FLT_FN (BUILT_IN_CEIL):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_CEIL):
          /* Only convert in ISO C99 mode.  */
          if (!targetm.libc_has_function (function_c99_misc))
            break;
@@ -570,6 +571,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
          break;
 
        CASE_FLT_FN (BUILT_IN_FLOOR):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_FLOOR):
          /* Only convert in ISO C99 mode.  */
          if (!targetm.libc_has_function (function_c99_misc))
            break;
@@ -586,6 +588,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
          break;
 
        CASE_FLT_FN (BUILT_IN_ROUND):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_ROUND):
          /* Only convert in ISO C99 mode and with -fno-math-errno.  */
          if (!targetm.libc_has_function (function_c99_misc) || flag_errno_math)
            break;
@@ -602,11 +605,13 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
          break;
 
        CASE_FLT_FN (BUILT_IN_NEARBYINT):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_NEARBYINT):
          /* Only convert nearbyint* if we can ignore math exceptions.  */
          if (flag_trapping_math)
            break;
          gcc_fallthrough ();
        CASE_FLT_FN (BUILT_IN_RINT):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_RINT):
          /* Only convert in ISO C99 mode and with -fno-math-errno.  */
          if (!targetm.libc_has_function (function_c99_misc) || flag_errno_math)
            break;
@@ -623,6 +628,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold)
          break;
 
        CASE_FLT_FN (BUILT_IN_TRUNC):
+       CASE_FLT_FN_FLOATN_NX (BUILT_IN_TRUNC):
          return convert_to_integer_1 (type, CALL_EXPR_ARG (s_expr, 0), dofold);
 
        default:
index 4d7059802368b6362013a56828cca0aec6e1ffed..c387ce529b138162edc950805384cce7755bc704 100644 (file)
@@ -718,6 +718,7 @@ fold_const_call_ss (real_value *result, combined_fn fn,
              && do_mpfr_arg1 (result, mpfr_y1, arg, format));
 
     CASE_CFN_FLOOR:
+    CASE_CFN_FLOOR_FN:
       if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
        {
          real_floor (result, format, arg);
@@ -726,6 +727,7 @@ fold_const_call_ss (real_value *result, combined_fn fn,
       return false;
 
     CASE_CFN_CEIL:
+    CASE_CFN_CEIL_FN:
       if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
        {
          real_ceil (result, format, arg);
@@ -734,10 +736,12 @@ fold_const_call_ss (real_value *result, combined_fn fn,
       return false;
 
     CASE_CFN_TRUNC:
+    CASE_CFN_TRUNC_FN:
       real_trunc (result, format, arg);
       return true;
 
     CASE_CFN_ROUND:
+    CASE_CFN_ROUND_FN:
       if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)
        {
          real_round (result, format, arg);
index 10a67b2e5f98be628e5a09f8a690ef8949286b6f..e776108c411d41239607783e4ba293046ae642df 100644 (file)
@@ -13004,9 +13004,11 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
     CASE_CFN_ATANH:
     CASE_CFN_CBRT:
     CASE_CFN_CEIL:
+    CASE_CFN_CEIL_FN:
     CASE_CFN_ERF:
     CASE_CFN_EXPM1:
     CASE_CFN_FLOOR:
+    CASE_CFN_FLOOR_FN:
     CASE_CFN_FMOD:
     CASE_CFN_FREXP:
     CASE_CFN_ICEIL:
@@ -13024,8 +13026,11 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
     CASE_CFN_LROUND:
     CASE_CFN_MODF:
     CASE_CFN_NEARBYINT:
+    CASE_CFN_NEARBYINT_FN:
     CASE_CFN_RINT:
+    CASE_CFN_RINT_FN:
     CASE_CFN_ROUND:
+    CASE_CFN_ROUND_FN:
     CASE_CFN_SCALB:
     CASE_CFN_SCALBLN:
     CASE_CFN_SCALBN:
@@ -13034,6 +13039,7 @@ tree_call_nonnegative_warnv_p (tree type, combined_fn fn, tree arg0, tree arg1,
     CASE_CFN_SINH:
     CASE_CFN_TANH:
     CASE_CFN_TRUNC:
+    CASE_CFN_TRUNC_FN:
       /* True if the 1st argument is nonnegative.  */
       return RECURSE (arg0);
 
@@ -13539,11 +13545,17 @@ integer_valued_real_call_p (combined_fn fn, tree arg0, tree arg1, int depth)
   switch (fn)
     {
     CASE_CFN_CEIL:
+    CASE_CFN_CEIL_FN:
     CASE_CFN_FLOOR:
+    CASE_CFN_FLOOR_FN:
     CASE_CFN_NEARBYINT:
+    CASE_CFN_NEARBYINT_FN:
     CASE_CFN_RINT:
+    CASE_CFN_RINT_FN:
     CASE_CFN_ROUND:
+    CASE_CFN_ROUND_FN:
     CASE_CFN_TRUNC:
+    CASE_CFN_TRUNC_FN:
       return true;
 
     CASE_CFN_FMIN:
index 5b38ac20a4d02d96a3b07f97f4028a474fd99e25..ae5b0c9f19e6cc9bd9997bd20569fd869a4da243 100644 (file)
@@ -94,13 +94,15 @@ is_group (string_set *builtins, const char *name, const char *const *suffixes)
 
 /* Print a macro for all combined functions related to NAME, with the
    null-terminated list of suffixes in SUFFIXES.  INTERNAL_P says whether
-   CFN_<NAME> also exists.  */
+   CFN_<NAME> also exists.  FLOATN_P is a suffix to the operator name, blank
+   for normal operators, "_FN" for _Float<N>/_Float<N>X operators only, and
+   "_ALL" for both the traditional operators and the _Float<N>/_Float<N>X
+   operators.  */
 
 static void
 print_case_cfn (const char *name, bool internal_p,
-               const char *const *suffixes, bool floatn_p)
+               const char *const *suffixes, const char *floatn)
 {
-  const char *floatn = (floatn_p) ? "_FN" : "";
   printf ("#define CASE_CFN_%s%s", name, floatn);
   if (internal_p)
     printf (" \\\n  case CFN_%s%s", name, floatn);
@@ -110,15 +112,18 @@ print_case_cfn (const char *name, bool internal_p,
   printf ("\n");
 }
 
-/* Print an operator list for all combined functions related to NAME,
-   with the null-terminated list of suffixes in SUFFIXES.  INTERNAL_P
-   says whether CFN_<NAME> also exists.  */
+/* Print an operator list for all combined functions related to NAME, with the
+   null-terminated list of suffixes in SUFFIXES.  INTERNAL_P says whether
+   CFN_<NAME> also exists.  FLOATN_P is a suffix to the operator name, blank
+   for normal operators, "_FN" for _Float<N>/_Float<N>X operators only, and
+   "_ALL" for both the traditional operators and the _Float<N>/_Float<N>X
+   operators.  */
 
 static void
 print_define_operator_list (const char *name, bool internal_p,
-                           const char *const *suffixes, bool floatn_p)
+                           const char *const *suffixes,
+                           const char *floatn)
 {
-  const char *floatn = (floatn_p) ? "_FN" : "";
   printf ("(define_operator_list %s%s\n", name, floatn);
   for (unsigned int i = 0; suffixes[i]; ++i)
     printf ("    BUILT_IN_%s%s\n", name, suffixes[i]);
@@ -152,6 +157,9 @@ const char *const internal_fn_int_names[] = {
 static const char *const flt_suffixes[] = { "F", "", "L", NULL };
 static const char *const fltfn_suffixes[] = { "F16", "F32", "F64", "F128",
                                              "F32X", "F64X", "F128X", NULL };
+static const char *const fltall_suffixes[] = { "F", "", "L", "F16", "F32",
+                                              "F64", "F128", "F32X", "F64X",
+                                              "F128X", NULL };
 static const char *const int_suffixes[] = { "", "L", "LL", "IMAX", NULL };
 
 static const char *const *const suffix_lists[] = {
@@ -212,22 +220,31 @@ main (int argc, char **argv)
                  bool internal_p = internal_fns.contains (root);
 
                  if (type == 'c')
-                   print_case_cfn (root, internal_p, suffix, false);
+                   print_case_cfn (root, internal_p, suffix, "");
                  else
-                   print_define_operator_list (root, internal_p,
-                                               suffix, false);
+                   print_define_operator_list (root, internal_p, suffix, "");
 
                      /* Support the _Float<N> and _Float<N>X math functions if
-                        they exist.  We put these out as a separate CFN macro,
-                        so code can add support or not as needed.  */
+                        they exist.  We put these out as a separate CFN or
+                        operator macro, so code can add support or not as
+                        needed.  We also put out a combined CFN or operator
+                        macro that includes both the traditional names and the
+                        _Float<N> and _Float<N>X versions.  */
                  if (suffix == flt_suffixes
                      && is_group (&builtins, root, fltfn_suffixes))
                    {
                      if (type == 'c')
-                       print_case_cfn (root, false, fltfn_suffixes, true);
+                       {
+                         print_case_cfn (root, false, fltfn_suffixes, "_FN");
+                         print_case_cfn (root, false, fltall_suffixes, "_ALL");
+                       }
                      else
-                       print_define_operator_list (root, false, fltfn_suffixes,
-                                                   true);
+                       {
+                         print_define_operator_list (root, false,
+                                                     fltfn_suffixes, "_FN");
+                         print_define_operator_list (root, internal_p,
+                                                     fltall_suffixes, "_ALL");
+                       }
                    }
                }
            }
index 07f9208b0acdf04a540c6fcf92bb0e49bc785156..e1f207cbf568b50f32d7590fad96953636128f4e 100644 (file)
@@ -139,12 +139,12 @@ DEF_INTERNAL_FLT_FLOATN_FN (SQRT, ECF_CONST, sqrt, unary)
 DEF_INTERNAL_FLT_FN (TAN, ECF_CONST, tan, unary)
 
 /* FP rounding.  */
-DEF_INTERNAL_FLT_FN (CEIL, ECF_CONST, ceil, unary)
-DEF_INTERNAL_FLT_FN (FLOOR, ECF_CONST, floor, unary)
-DEF_INTERNAL_FLT_FN (NEARBYINT, ECF_CONST, nearbyint, unary)
-DEF_INTERNAL_FLT_FN (RINT, ECF_CONST, rint, unary)
-DEF_INTERNAL_FLT_FN (ROUND, ECF_CONST, round, unary)
-DEF_INTERNAL_FLT_FN (TRUNC, ECF_CONST, btrunc, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (CEIL, ECF_CONST, ceil, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (FLOOR, ECF_CONST, floor, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (NEARBYINT, ECF_CONST, nearbyint, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (RINT, ECF_CONST, rint, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (ROUND, ECF_CONST, round, unary)
+DEF_INTERNAL_FLT_FLOATN_FN (TRUNC, ECF_CONST, btrunc, unary)
 
 /* Binary math functions.  */
 DEF_INTERNAL_FLT_FN (ATAN2, ECF_CONST, atan2, binary)
index bd1673ac5e978aa66575c0d356f1e347b0768857..87012a243191e23e719a0e2766447c83d7adba91 100644 (file)
@@ -199,21 +199,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 /* Transform X * copysign (1.0, X) into abs(X). */
 (simplify
- (mult:c @0 (COPYSIGN real_onep @0))
+ (mult:c @0 (COPYSIGN_ALL real_onep @0))
  (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type))
   (abs @0)))
 
 /* Transform X * copysign (1.0, -X) into -abs(X). */
 (simplify
- (mult:c @0 (COPYSIGN real_onep (negate @0)))
+ (mult:c @0 (COPYSIGN_ALL real_onep (negate @0)))
  (if (!HONOR_NANS (type) && !HONOR_SIGNED_ZEROS (type))
   (negate (abs @0))))
 
 /* Transform copysign (CST, X) into copysign (ABS(CST), X). */
 (simplify
- (COPYSIGN REAL_CST@0 @1)
+ (COPYSIGN_ALL REAL_CST@0 @1)
  (if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (@0)))
-  (COPYSIGN (negate @0) @1)))
+  (COPYSIGN_ALL (negate @0) @1)))
 
 /* X * 1, X / 1 -> X.  */
 (for op (mult trunc_div ceil_div floor_div round_div exact_div)
@@ -542,7 +542,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (hypots @0 (op @1))
    (hypots @0 @1)))
  /* copysign(-x, y) and copysign(abs(x), y) -> copysign(x, y).  */
- (for copysigns (COPYSIGN)
+ (for copysigns (COPYSIGN_ALL)
   (simplify
    (copysigns (op @0) @1)
    (copysigns @0 @1))))
@@ -587,7 +587,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (hypots @0 @1)))
 
 /* copysign(x, CST) -> [-]abs (x).  */
-(for copysigns (COPYSIGN)
+(for copysigns (COPYSIGN_ALL)
  (simplify
   (copysigns @0 REAL_CST@1)
   (if (REAL_VALUE_NEGATIVE (TREE_REAL_CST (@1)))
@@ -595,13 +595,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    (abs @0))))
 
 /* copysign(copysign(x, y), z) -> copysign(x, z).  */
-(for copysigns (COPYSIGN)
+(for copysigns (COPYSIGN_ALL)
  (simplify
   (copysigns (copysigns @0 @1) @2)
   (copysigns @0 @2)))
 
 /* copysign(x,y)*copysign(x,y) -> x*x.  */
-(for copysigns (COPYSIGN)
+(for copysigns (COPYSIGN_ALL)
  (simplify
   (mult (copysigns@2 @0 @1) @2)
   (mult @0 @0)))
@@ -1914,7 +1914,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 /* Simplifications of MIN_EXPR, MAX_EXPR, fmin() and fmax().  */
 
-(for minmax (min max FMIN FMIN_FN FMAX FMAX_FN)
+(for minmax (min max FMIN_ALL FMAX_ALL)
  (simplify
   (minmax @0 @0)
   @0))
@@ -1992,7 +1992,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
        && TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type))
    (minmax @1 (convert @2)))))
 
-(for minmax (FMIN FMIN_FN FMAX FMAX_FN)
+(for minmax (FMIN_ALL FMAX_ALL)
  /* If either argument is NaN, return the other one.  Avoid the
     transformation if we get (and honor) a signalling NaN.  */
  (simplify
@@ -2007,20 +2007,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
    worry about it either.  */
 (if (flag_finite_math_only)
  (simplify
-  (FMIN @0 @1)
+  (FMIN_ALL @0 @1)
   (min @0 @1))
  (simplify
-  (FMIN_FN @0 @1)
-  (min @0 @1))
- (simplify
-  (FMAX @0 @1)
-  (max @0 @1))
- (simplify
-  (FMAX_FN @0 @1)
+  (FMAX_ALL @0 @1)
   (max @0 @1)))
 /* min (-A, -B) -> -max (A, B)  */
-(for minmax (min max FMIN FMIN_FN FMAX FMAX_FN)
-     maxmin (max min FMAX FMAX_FN FMIN FMAX_FN)
+(for minmax (min max FMIN_ALL FMAX_ALL)
+     maxmin (max min FMAX_ALL FMIN_ALL)
  (simplify
   (minmax (negate:s@2 @0) (negate:s@3 @1))
   (if (FLOAT_TYPE_P (TREE_TYPE (@0))
@@ -3814,7 +3808,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (if (flag_unsafe_math_optimizations)
  /* Simplify sqrt(x) * sqrt(x) -> x.  */
  (simplify
-  (mult (SQRT@1 @0) @1)
+  (mult (SQRT_ALL@1 @0) @1)
   (if (!HONOR_SNANS (type))
    @0))
 
@@ -3967,12 +3961,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (abs @0))
 
 /* trunc(trunc(x)) -> trunc(x), etc.  */
-(for fns (TRUNC FLOOR CEIL ROUND NEARBYINT RINT)
+(for fns (TRUNC_ALL FLOOR_ALL CEIL_ALL ROUND_ALL NEARBYINT_ALL RINT_ALL)
  (simplify
   (fns (fns @0))
   (fns @0)))
 /* f(x) -> x if x is integer valued and f does nothing for such values.  */
-(for fns (TRUNC FLOOR CEIL ROUND NEARBYINT RINT)
+(for fns (TRUNC_ALL FLOOR_ALL CEIL_ALL ROUND_ALL NEARBYINT_ALL RINT_ALL)
  (simplify
   (fns integer_valued_real_p@0)
   @0))
@@ -3989,12 +3983,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 (simplify
  /* copysign(x,x) -> x.  */
- (COPYSIGN @0 @0)
+ (COPYSIGN_ALL @0 @0)
  @0)
 
 (simplify
  /* copysign(x,y) -> fabs(x) if y is nonnegative.  */
- (COPYSIGN @0 tree_expr_nonnegative_p@1)
+ (COPYSIGN_ALL @0 tree_expr_nonnegative_p@1)
  (abs @0))
 
 (for scale (LDEXP SCALBN SCALBLN)
@@ -4145,8 +4139,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 
 (if (canonicalize_math_p ())
  /* floor(x) -> trunc(x) if x is nonnegative.  */
- (for floors (FLOOR)
-      truncs (TRUNC)
+ (for floors (FLOOR_ALL)
+      truncs (TRUNC_ALL)
   (simplify
    (floors tree_expr_nonnegative_p@0)
    (truncs @0))))