diff options
author | Uros Bizjak <ubizjak@gmail.com> | 2011-08-12 14:32:41 +0200 |
---|---|---|
committer | Uros Bizjak <uros@gcc.gnu.org> | 2011-08-12 14:32:41 +0200 |
commit | 6c32ee74491f947dafdce3656c6ec9e48a185fdb (patch) | |
tree | cd499a40f57a9bb51448aec4aefe1d8a6decc748 /gcc | |
parent | d9fbc86e446fd574db0d79c3af8d0bd2b1cdc820 (diff) | |
download | gcc-6c32ee74491f947dafdce3656c6ec9e48a185fdb.zip gcc-6c32ee74491f947dafdce3656c6ec9e48a185fdb.tar.gz gcc-6c32ee74491f947dafdce3656c6ec9e48a185fdb.tar.bz2 |
builtins.def (BUILT_IN_ICEIL{,F,L}, [...]): New builtin definitions.
* 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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 19 | ||||
-rw-r--r-- | gcc/builtins.c | 63 | ||||
-rw-r--r-- | gcc/builtins.def | 12 | ||||
-rw-r--r-- | gcc/convert.c | 28 | ||||
-rw-r--r-- | gcc/fold-const.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/builtins-67.c | 72 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/conversion.c | 56 |
8 files changed, 251 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e708c8e..5698e96 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/builtins.c b/gcc/builtins.c index 6c16821..fec9322 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -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); diff --git a/gcc/builtins.def b/gcc/builtins.def index fc5664f..424f0f1 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -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) diff --git a/gcc/convert.c b/gcc/convert.c index 84ba13d..d72dda8 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -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)) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0cdf682..6abce59 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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): diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a18bf7e..38079fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..0863955 --- /dev/null +++ b/gcc/testsuite/gcc.dg/builtins-67.c @@ -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 index 0000000..bc71211 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/conversion.c @@ -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; } |