diff options
author | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-12 12:32:41 +0000 |
---|---|---|
committer | uros <uros@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-12 12:32:41 +0000 |
commit | 80ff6494828aec552c700b031d2db3c145aee430 (patch) | |
tree | cd499a40f57a9bb51448aec4aefe1d8a6decc748 /gcc/convert.c | |
parent | 77c6bddba9214b817d28544564c7cd1274c23ab9 (diff) | |
download | gcc-80ff6494828aec552c700b031d2db3c145aee430.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/convert.c')
-rw-r--r-- | gcc/convert.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/gcc/convert.c b/gcc/convert.c index 84ba13d1812..d72dda8fd82 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)) |