builtins.def (BUILT_IN_ICEIL{,F,L}, [...]): New builtin definitions.
authorUros Bizjak <ubizjak@gmail.com>
Fri, 12 Aug 2011 12:32:41 +0000 (14:32 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 12 Aug 2011 12:32:41 +0000 (14:32 +0200)
* builtins.def (BUILT_IN_ICEIL{,F,L}, BUILT_IN_IFLOOR{,F,L}
BUILT_IN_IRINT{,F,L}, BUILT_IN_IROUND{,F,L}: New builtin definitions.
* convert.c (convert_to_integer): Convert to BUILT_IN_ICEIL,
BUILT_IN_IFLOOR, BUILT_IN_IRINT or BUILT_INT_IROUND when converting
to integer_type_node.
* fold-const.c (tree_call_nonnegative_warnv_p): Handle BUILT_IN_ICEIL,
BUILT_IN_IFLOOR, BUILT_IN_IRINT and BUILT_INT_IROUND.
* builtins.c (expand_builtin_in): Ditto.
(mathfn_built_in_1): Ditto.
(expand_builtin_int_roundingfn): Handle BUILT_IN_ICEIL and
BUILT_IN_IFLOOR.
(expand_builtin_int_roundingfn_2): Handle BUILT_IN_IRINT and
BUILT_IN_IROUND.
(fold_fixed_mathfn): Canonicalize BUILT_IN_ICEIL, BUILTIN_IN_IFLOOR
BUILT_IN_IRINT and BUILT_IN_IROUND to BUILT_IN_LCEIL,
BUILTIN_IN_LFLOOR, BUILT_IN_LRINT and BUILT_IN_LROUND on ILP32 targets.

testsuite/ChangeLog:

* gcc.dg/builtins-67.c: New test.
* gcc.target/i386/conversion.c: Ditto.

From-SVN: r177694

gcc/ChangeLog
gcc/builtins.c
gcc/builtins.def
gcc/convert.c
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-67.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/conversion.c [new file with mode: 0644]

index e708c8ea9f57a452dec0bc1a2a476a1061c7544f..5698e9689ce628c8ce477258a33be1b04409bce3 100644 (file)
@@ -1,3 +1,22 @@
+2011-08-12  Uros Bizjak  <ubizjak@gmail.com>
+
+       * builtins.def (BUILT_IN_ICEIL{,F,L}, BUILT_IN_IFLOOR{,F,L}
+       BUILT_IN_IRINT{,F,L}, BUILT_IN_IROUND{,F,L}: New builtin definitions.
+       * convert.c (convert_to_integer): Convert to BUILT_IN_ICEIL,
+       BUILT_IN_IFLOOR, BUILT_IN_IRINT or BUILT_INT_IROUND when converting
+       to integer_type_node.
+       * fold-const.c (tree_call_nonnegative_warnv_p): Handle BUILT_IN_ICEIL,
+       BUILT_IN_IFLOOR, BUILT_IN_IRINT and BUILT_INT_IROUND.
+       * builtins.c (expand_builtin_in): Ditto.
+       (mathfn_built_in_1): Ditto.
+       (expand_builtin_int_roundingfn): Handle BUILT_IN_ICEIL and
+       BUILT_IN_IFLOOR.
+       (expand_builtin_int_roundingfn_2): Handle BUILT_IN_IRINT and
+       BUILT_IN_IROUND.
+       (fold_fixed_mathfn): Canonicalize BUILT_IN_ICEIL, BUILTIN_IN_IFLOOR
+       BUILT_IN_IRINT and BUILT_IN_IROUND to BUILT_IN_LCEIL,
+       BUILTIN_IN_LFLOOR, BUILT_IN_LRINT and BUILT_IN_LROUND on ILP32 targets.
+
 2011-08-12  Richard Guenther  <rguenther@suse.de>
 
        * tree-vrp.c (extract_range_from_unary_expr_1): Implement
index 6c16821c348759028e682961192b38c69e6506dc..fec93221faa7a64a1a39cd6c71bf02eb0c3ff43e 100644 (file)
@@ -1837,7 +1837,11 @@ mathfn_built_in_1 (tree type, enum built_in_function fn, bool implicit)
       CASE_MATHFN (BUILT_IN_HUGE_VAL)
       CASE_MATHFN (BUILT_IN_HYPOT)
       CASE_MATHFN (BUILT_IN_ILOGB)
+      CASE_MATHFN (BUILT_IN_ICEIL)
+      CASE_MATHFN (BUILT_IN_IFLOOR)
       CASE_MATHFN (BUILT_IN_INF)
+      CASE_MATHFN (BUILT_IN_IRINT)
+      CASE_MATHFN (BUILT_IN_IROUND)
       CASE_MATHFN (BUILT_IN_ISINF)
       CASE_MATHFN (BUILT_IN_J0)
       CASE_MATHFN (BUILT_IN_J1)
@@ -2662,12 +2666,14 @@ expand_builtin_int_roundingfn (tree exp, rtx target)
 
   switch (DECL_FUNCTION_CODE (fndecl))
     {
+    CASE_FLT_FN (BUILT_IN_ICEIL):
     CASE_FLT_FN (BUILT_IN_LCEIL):
     CASE_FLT_FN (BUILT_IN_LLCEIL):
       builtin_optab = lceil_optab;
       fallback_fn = BUILT_IN_CEIL;
       break;
 
+    CASE_FLT_FN (BUILT_IN_IFLOOR):
     CASE_FLT_FN (BUILT_IN_LFLOOR):
     CASE_FLT_FN (BUILT_IN_LLFLOOR):
       builtin_optab = lfloor_optab;
@@ -2720,26 +2726,32 @@ expand_builtin_int_roundingfn (tree exp, rtx target)
 
       switch (DECL_FUNCTION_CODE (fndecl))
        {
+       case BUILT_IN_ICEIL:
        case BUILT_IN_LCEIL:
        case BUILT_IN_LLCEIL:
          name = "ceil";
          break;
+       case BUILT_IN_ICEILF:
        case BUILT_IN_LCEILF:
        case BUILT_IN_LLCEILF:
          name = "ceilf";
          break;
+       case BUILT_IN_ICEILL:
        case BUILT_IN_LCEILL:
        case BUILT_IN_LLCEILL:
          name = "ceill";
          break;
+       case BUILT_IN_IFLOOR:
        case BUILT_IN_LFLOOR:
        case BUILT_IN_LLFLOOR:
          name = "floor";
          break;
+       case BUILT_IN_IFLOORF:
        case BUILT_IN_LFLOORF:
        case BUILT_IN_LLFLOORF:
          name = "floorf";
          break;
+       case BUILT_IN_IFLOORL:
        case BUILT_IN_LFLOORL:
        case BUILT_IN_LLFLOORL:
          name = "floorl";
@@ -2791,12 +2803,16 @@ expand_builtin_int_roundingfn_2 (tree exp, rtx target)
 
   switch (DECL_FUNCTION_CODE (fndecl))
     {
+    CASE_FLT_FN (BUILT_IN_IRINT):
     CASE_FLT_FN (BUILT_IN_LRINT):
     CASE_FLT_FN (BUILT_IN_LLRINT):
       builtin_optab = lrint_optab; break;
+
+    CASE_FLT_FN (BUILT_IN_IROUND):
     CASE_FLT_FN (BUILT_IN_LROUND):
     CASE_FLT_FN (BUILT_IN_LLROUND):
       builtin_optab = lround_optab; break;
+
     default:
       gcc_unreachable ();
     }
@@ -5401,17 +5417,21 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode,
        return target;
       break;
 
+    CASE_FLT_FN (BUILT_IN_ICEIL):
     CASE_FLT_FN (BUILT_IN_LCEIL):
     CASE_FLT_FN (BUILT_IN_LLCEIL):
     CASE_FLT_FN (BUILT_IN_LFLOOR):
+    CASE_FLT_FN (BUILT_IN_IFLOOR):
     CASE_FLT_FN (BUILT_IN_LLFLOOR):
       target = expand_builtin_int_roundingfn (exp, target);
       if (target)
        return target;
       break;
 
+    CASE_FLT_FN (BUILT_IN_IRINT):
     CASE_FLT_FN (BUILT_IN_LRINT):
     CASE_FLT_FN (BUILT_IN_LLRINT):
+    CASE_FLT_FN (BUILT_IN_IROUND):
     CASE_FLT_FN (BUILT_IN_LROUND):
     CASE_FLT_FN (BUILT_IN_LLROUND):
       target = expand_builtin_int_roundingfn_2 (exp, target);
@@ -6521,6 +6541,42 @@ fold_fixed_mathfn (location_t loc, tree fndecl, tree arg)
                                fold_convert_loc (loc, newtype, arg0));
     }
 
+  /* Canonicalize iround (x) to lround (x) on ILP32 targets where
+     sizeof (int) == sizeof (long).  */
+  if (TYPE_PRECISION (integer_type_node)
+      == TYPE_PRECISION (long_integer_type_node))
+    {
+      tree newfn = NULL_TREE;
+      switch (fcode)
+       {
+       CASE_FLT_FN (BUILT_IN_ICEIL):
+         newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LCEIL);
+         break;
+
+       CASE_FLT_FN (BUILT_IN_IFLOOR):
+         newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LFLOOR);
+         break;
+
+       CASE_FLT_FN (BUILT_IN_IROUND):
+         newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LROUND);
+         break;
+
+       CASE_FLT_FN (BUILT_IN_IRINT):
+         newfn = mathfn_built_in (TREE_TYPE (arg), BUILT_IN_LRINT);
+         break;
+
+       default:
+         break;
+       }
+
+      if (newfn)
+       {
+         tree newcall = build_call_expr_loc (loc, newfn, 1, arg);
+         return fold_convert_loc (loc,
+                                  TREE_TYPE (TREE_TYPE (fndecl)), newcall);
+       }
+    }
+
   /* Canonicalize llround (x) to lround (x) on LP64 targets where
      sizeof (long long) == sizeof (long).  */
   if (TYPE_PRECISION (long_long_integer_type_node)
@@ -7220,16 +7276,19 @@ fold_builtin_int_roundingfn (location_t loc, tree fndecl, tree arg)
 
          switch (DECL_FUNCTION_CODE (fndecl))
            {
+           CASE_FLT_FN (BUILT_IN_IFLOOR):
            CASE_FLT_FN (BUILT_IN_LFLOOR):
            CASE_FLT_FN (BUILT_IN_LLFLOOR):
              real_floor (&r, TYPE_MODE (ftype), &x);
              break;
 
+           CASE_FLT_FN (BUILT_IN_ICEIL):
            CASE_FLT_FN (BUILT_IN_LCEIL):
            CASE_FLT_FN (BUILT_IN_LLCEIL):
              real_ceil (&r, TYPE_MODE (ftype), &x);
              break;
 
+           CASE_FLT_FN (BUILT_IN_IROUND):
            CASE_FLT_FN (BUILT_IN_LROUND):
            CASE_FLT_FN (BUILT_IN_LLROUND):
              real_round (&r, TYPE_MODE (ftype), &x);
@@ -9758,14 +9817,18 @@ fold_builtin_1 (location_t loc, tree fndecl, tree arg0, bool ignore)
     CASE_FLT_FN (BUILT_IN_RINT):
       return fold_trunc_transparent_mathfn (loc, fndecl, arg0);
 
+    CASE_FLT_FN (BUILT_IN_ICEIL):
     CASE_FLT_FN (BUILT_IN_LCEIL):
     CASE_FLT_FN (BUILT_IN_LLCEIL):
     CASE_FLT_FN (BUILT_IN_LFLOOR):
+    CASE_FLT_FN (BUILT_IN_IFLOOR):
     CASE_FLT_FN (BUILT_IN_LLFLOOR):
+    CASE_FLT_FN (BUILT_IN_IROUND):
     CASE_FLT_FN (BUILT_IN_LROUND):
     CASE_FLT_FN (BUILT_IN_LLROUND):
       return fold_builtin_int_roundingfn (loc, fndecl, arg0);
 
+    CASE_FLT_FN (BUILT_IN_IRINT):
     CASE_FLT_FN (BUILT_IN_LRINT):
     CASE_FLT_FN (BUILT_IN_LLRINT):
       return fold_fixed_mathfn (loc, fndecl, arg0);
index fc5664fb8e1ba94dbe554aedc4b07ecfa181ef83..424f0f1a0853366277367a8606c7f65fa9d6becc 100644 (file)
@@ -267,6 +267,12 @@ DEF_GCC_BUILTIN        (BUILT_IN_HUGE_VALL, "huge_vall", BT_FN_LONGDOUBLE, ATTR_
 DEF_C99_BUILTIN        (BUILT_IN_HYPOT, "hypot", BT_FN_DOUBLE_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_HYPOTF, "hypotf", BT_FN_FLOAT_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_HYPOTL, "hypotl", BT_FN_LONGDOUBLE_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_ICEIL, "iceil", BT_FN_INT_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_ICEILF, "iceilf", BT_FN_INT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_ICEILL, "iceill", BT_FN_INT_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_IFLOOR, "ifloor", BT_FN_INT_DOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_IFLOORF, "ifloorf", BT_FN_INT_FLOAT, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_IFLOORL, "ifloorl", BT_FN_INT_LONGDOUBLE, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_C99_BUILTIN        (BUILT_IN_ILOGB, "ilogb", BT_FN_INT_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_ILOGBF, "ilogbf", BT_FN_INT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_C99_BUILTIN        (BUILT_IN_ILOGBL, "ilogbl", BT_FN_INT_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
@@ -276,6 +282,12 @@ DEF_GCC_BUILTIN        (BUILT_IN_INFL, "infl", BT_FN_LONGDOUBLE, ATTR_CONST_NOTH
 DEF_GCC_BUILTIN               (BUILT_IN_INFD32, "infd32", BT_FN_DFLOAT32, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_INFD64, "infd64", BT_FN_DFLOAT64, ATTR_CONST_NOTHROW_LEAF_LIST)
 DEF_GCC_BUILTIN        (BUILT_IN_INFD128, "infd128", BT_FN_DFLOAT128, ATTR_CONST_NOTHROW_LEAF_LIST)
+DEF_GCC_BUILTIN        (BUILT_IN_IRINT, "irint", BT_FN_INT_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_IRINTF, "irintf", BT_FN_INT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_IRINTL, "irintl", BT_FN_INT_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_IROUND, "iround", BT_FN_INT_DOUBLE, ATTR_MATHFN_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_IROUNDF, "iroundf", BT_FN_INT_FLOAT, ATTR_MATHFN_ERRNO)
+DEF_GCC_BUILTIN        (BUILT_IN_IROUNDL, "iroundl", BT_FN_INT_LONGDOUBLE, ATTR_MATHFN_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_J0, "j0", BT_FN_DOUBLE_DOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_J0F, "j0f", BT_FN_FLOAT_FLOAT, ATTR_MATHFN_FPROUNDING_ERRNO)
 DEF_EXT_LIB_BUILTIN    (BUILT_IN_J0L, "j0l", BT_FN_LONGDOUBLE_LONGDOUBLE, ATTR_MATHFN_FPROUNDING_ERRNO)
index 84ba13d1812f4b3439fceee55d2ad5d7c6ca4646..d72dda8fd826aaf48c9886e436c39a1980cdcaad 100644 (file)
@@ -440,9 +440,12 @@ convert_to_integer (tree type, tree expr)
          /* Only convert in ISO C99 mode.  */
          if (!TARGET_C99_FUNCTIONS)
            break;
-         if (outprec < TYPE_PRECISION (long_integer_type_node)
-             || (outprec == TYPE_PRECISION (long_integer_type_node)
+         if (outprec < TYPE_PRECISION (integer_type_node)
+             || (outprec == TYPE_PRECISION (integer_type_node)
                  && !TYPE_UNSIGNED (type)))
+           fn = mathfn_built_in (s_intype, BUILT_IN_ICEIL);
+         else if (outprec == TYPE_PRECISION (long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
            fn = mathfn_built_in (s_intype, BUILT_IN_LCEIL);
          else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
                   && !TYPE_UNSIGNED (type))
@@ -453,9 +456,12 @@ convert_to_integer (tree type, tree expr)
          /* Only convert in ISO C99 mode.  */
          if (!TARGET_C99_FUNCTIONS)
            break;
-         if (outprec < TYPE_PRECISION (long_integer_type_node)
-             || (outprec == TYPE_PRECISION (long_integer_type_node)
+         if (outprec < TYPE_PRECISION (integer_type_node)
+             || (outprec == TYPE_PRECISION (integer_type_node)
                  && !TYPE_UNSIGNED (type)))
+           fn = mathfn_built_in (s_intype, BUILT_IN_IFLOOR);
+         else if (outprec == TYPE_PRECISION (long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
            fn = mathfn_built_in (s_intype, BUILT_IN_LFLOOR);
          else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
                   && !TYPE_UNSIGNED (type))
@@ -463,9 +469,12 @@ convert_to_integer (tree type, tree expr)
          break;
 
        CASE_FLT_FN (BUILT_IN_ROUND):
-         if (outprec < TYPE_PRECISION (long_integer_type_node)
-             || (outprec == TYPE_PRECISION (long_integer_type_node)
+         if (outprec < TYPE_PRECISION (integer_type_node)
+             || (outprec == TYPE_PRECISION (integer_type_node)
                  && !TYPE_UNSIGNED (type)))
+           fn = mathfn_built_in (s_intype, BUILT_IN_IROUND);
+         else if (outprec == TYPE_PRECISION (long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
            fn = mathfn_built_in (s_intype, BUILT_IN_LROUND);
          else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
                   && !TYPE_UNSIGNED (type))
@@ -478,9 +487,12 @@ convert_to_integer (tree type, tree expr)
            break;
          /* ... Fall through ...  */
        CASE_FLT_FN (BUILT_IN_RINT):
-         if (outprec < TYPE_PRECISION (long_integer_type_node)
-             || (outprec == TYPE_PRECISION (long_integer_type_node)
+         if (outprec < TYPE_PRECISION (integer_type_node)
+             || (outprec == TYPE_PRECISION (integer_type_node)
                  && !TYPE_UNSIGNED (type)))
+           fn = mathfn_built_in (s_intype, BUILT_IN_IRINT);
+         else if (outprec < TYPE_PRECISION (long_integer_type_node)
+                  && !TYPE_UNSIGNED (type))
            fn = mathfn_built_in (s_intype, BUILT_IN_LRINT);
          else if (outprec == TYPE_PRECISION (long_long_integer_type_node)
                   && !TYPE_UNSIGNED (type))
index 0cdf682ae386518d844f394b7f2c13638345c8c7..6abce5924e91db0d6591aa3d5af28e82532d17ca 100644 (file)
@@ -14670,6 +14670,10 @@ tree_call_nonnegative_warnv_p (tree type, tree fndecl,
        CASE_FLT_FN (BUILT_IN_FLOOR):
        CASE_FLT_FN (BUILT_IN_FMOD):
        CASE_FLT_FN (BUILT_IN_FREXP):
+       CASE_FLT_FN (BUILT_IN_ICEIL):
+       CASE_FLT_FN (BUILT_IN_IFLOOR):
+       CASE_FLT_FN (BUILT_IN_IRINT):
+       CASE_FLT_FN (BUILT_IN_IROUND):
        CASE_FLT_FN (BUILT_IN_LCEIL):
        CASE_FLT_FN (BUILT_IN_LDEXP):
        CASE_FLT_FN (BUILT_IN_LFLOOR):
index a18bf7e9def6147d3100430cc20ee79ea2b98367..38079faf7715d081fe1dc0e4522e5ab02e94a1d9 100644 (file)
@@ -1,3 +1,8 @@
+2011-08-12  Uros Bizjak  <ubizjak@gmail.com>
+
+       * gcc.dg/builtins-67.c: New test.
+       * gcc.target/i386/conversion.c: Ditto.
+
 2011-08-11  Romain Geissler  <romain.geissler@gmail.com>
             Brian Hackett  <bhackett1024@gmail.com>
 
diff --git a/gcc/testsuite/gcc.dg/builtins-67.c b/gcc/testsuite/gcc.dg/builtins-67.c
new file mode 100644 (file)
index 0000000..0863955
--- /dev/null
@@ -0,0 +1,72 @@
+/* Check that conversion functions link correctly with -ffast-math.  */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math -lm" }  */
+
+#include "builtins-config.h"
+
+double floor (double);
+float floorf (float);
+long double floorl (long double);
+
+double ceil (double);
+float ceilf (float);
+long double ceill (long double);
+
+double round (double);
+float roundf (float);
+long double roundl (long double);
+
+double rint (double);
+float rintf (float);
+long double rintl (long double);
+
+int ifloor (double a) { return (int) floor (a); }
+#ifdef HAVE_C99_RUNTIME
+int ifloorf (float a) { return (int) floorf (a); }
+int ifloorl (long double a) { return (int) floorl (a); }
+#endif
+
+long lfloor (double a) { return (long) floor (a); }
+#ifdef HAVE_C99_RUNTIME
+long lfloorf (float a) { return (long) floorf (a); }
+long lfloorl (long double a) { return (long) floorl (a); }
+#endif
+
+long long llfloor (double a) { return (long long) floor (a); }
+#ifdef HAVE_C99_RUNTIME
+long long llfloorf (float a) { return (long long) floorf (a); }
+long long llfloorl (long double a) { return (long long) floorl (a); }
+#endif
+
+int iceil (double a) { return (int) ceil (a); }
+#ifdef HAVE_C99_RUNTIME
+int iceilf (float a) { return (int) ceilf (a); }
+int iceill (long double a) { return (int) ceill (a); }
+#endif
+
+long lceil (double a) { return (long) ceil (a); }
+#ifdef HAVE_C99_RUNTIME
+long lceilf (float a) { return (long) ceilf (a); }
+long lceill (long double a) { return (long) ceill (a); }
+#endif
+
+long long llceil (double a) { return (long long) ceil (a); }
+#ifdef HAVE_C99_RUNTIME
+long long llceilf (float a) { return (long long) ceilf (a); }
+long long llceill (long double a) { return (long long) ceill (a); }
+#endif
+
+int iround (double a) { return (int) round (a); }
+#ifdef HAVE_C99_RUNTIME
+int iroundf (float a) { return (int) roundf (a); }
+int iroundl (long double a) { return (int) roundl (a); }
+#endif
+
+int irint (double a) { return (int) rint (a); }
+#ifdef HAVE_C99_RUNTIME
+int irintf (float a) { return (int) rintf (a); }
+int irintl (long double a) { return (int) rintl (a); }
+#endif
+
+int main () { return 0; }
diff --git a/gcc/testsuite/gcc.target/i386/conversion.c b/gcc/testsuite/gcc.target/i386/conversion.c
new file mode 100644 (file)
index 0000000..bc71211
--- /dev/null
@@ -0,0 +1,56 @@
+/* Check that conversion functions don't leak into global namespace.  */
+
+/* { dg-do link } */
+/* { dg-options "-ffast-math" }  */
+
+#include "../../gcc.dg/builtins-config.h"
+
+int ifloor (double a) { return __builtin_ifloor (a); }
+#ifdef HAVE_C99_RUNTIME
+int ifloorf (float a) { return __builtin_ifloorf (a); }
+int ifloorl (long double a) { return __builtin_ifloorl (a); }
+#endif
+
+long lfloor (double a) { return __builtin_lfloor (a); }
+#ifdef HAVE_C99_RUNTIME
+long lfloorf (float a) { return __builtin_lfloorf (a); }
+long lfloorl (long double a) { return __builtin_lfloorl (a); }
+#endif
+
+long long llfloor (double a) { return __builtin_llfloor (a); }
+#ifdef HAVE_C99_RUNTIME
+long long llfloorf (float a) { return __builtin_llfloorf (a); }
+long long llfloorl (long double a) { return __builtin_llfloorl (a); }
+#endif
+
+int iceil (double a) { return __builtin_iceil (a); }
+#ifdef HAVE_C99_RUNTIME
+int iceilf (float a) { return __builtin_iceilf (a); }
+int iceill (long double a) { return __builtin_iceill (a); }
+#endif
+
+long lceil (double a) { return __builtin_lceil (a); }
+#ifdef HAVE_C99_RUNTIME
+long lceilf (float a) { return __builtin_lceilf (a); }
+long lceill (long double a) { return __builtin_lceill (a); }
+#endif
+
+long long llceil (double a) { return __builtin_llceil (a); }
+#ifdef HAVE_C99_RUNTIME
+long long llceilf (float a) { return __builtin_llceilf (a); }
+long long llceill (long double a) { return __builtin_llceill (a); }
+#endif
+
+int iround (double a) { return __builtin_iround (a); }
+#ifdef HAVE_C99_RUNTIME
+int iroundf (float a) { return __builtin_iroundf (a); }
+int iroundl (long double a) { return __builtin_iroundl (a); }
+#endif
+
+int irint (double a) { return __builtin_irint (a); }
+#ifdef HAVE_C99_RUNTIME
+int irintf (float a) { return __builtin_irintf (a); }
+int irintl (long double a) { return __builtin_irintl (a); }
+#endif
+
+int main () { return 0; }