diff options
author | Kaveh R. Ghazi <ghazi@caip.rutgers.edu> | 2006-11-12 23:51:36 +0000 |
---|---|---|
committer | Kaveh Ghazi <ghazi@gcc.gnu.org> | 2006-11-12 23:51:36 +0000 |
commit | 5c5b21550c5b1b9631b0d14569cc47f6d16dfc7b (patch) | |
tree | 9a539cef8be2437dc8b524015aa3a340c925fa7d /gcc/builtins.c | |
parent | 8f8bb1d2008496ba3856bc12f8b2cae12195c235 (diff) | |
download | gcc-5c5b21550c5b1b9631b0d14569cc47f6d16dfc7b.zip gcc-5c5b21550c5b1b9631b0d14569cc47f6d16dfc7b.tar.gz gcc-5c5b21550c5b1b9631b0d14569cc47f6d16dfc7b.tar.bz2 |
builtins.c (fold_builtin_cosh): New.
* builtins.c (fold_builtin_cosh): New.
(fold_builtin_1): Use it.
* fold-const.c (negate_mathfn_p): Add llround, lround, round,
trunc to the list of "odd" functions. Also add llrint, lrint,
rint and nearbyint when flag_rounding_math is false.
testsuite:
* gcc.dg/torture/builtin-symmetric-1.c: Add more cases.
From-SVN: r118733
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index 3d82b6b..b9005b4 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -151,6 +151,7 @@ static tree fold_builtin_cbrt (tree, tree); static tree fold_builtin_pow (tree, tree, tree); static tree fold_builtin_powi (tree, tree, tree); static tree fold_builtin_cos (tree, tree, tree); +static tree fold_builtin_cosh (tree, tree, tree); static tree fold_builtin_tan (tree, tree); static tree fold_builtin_trunc (tree, tree); static tree fold_builtin_floor (tree, tree); @@ -7121,6 +7122,29 @@ fold_builtin_cos (tree arglist, tree type, tree fndecl) return NULL_TREE; } +/* Fold function call to builtin cosh, coshf, or coshl. Return + NULL_TREE if no simplification can be made. */ +static tree +fold_builtin_cosh (tree arglist, tree type, tree fndecl) +{ + if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) + { + tree arg = TREE_VALUE (arglist); + tree res, narg; + + /* Calculate the result when the argument is a constant. */ + if ((res = do_mpfr_arg1 (arg, type, mpfr_cosh, NULL, NULL, 0))) + return res; + + /* Optimize cosh(-x) into cosh (x). */ + if ((narg = fold_strip_sign_ops (arg))) + return build_function_call_expr (fndecl, + build_tree_list (NULL_TREE, narg)); + } + + return NULL_TREE; +} + /* Fold function call to builtin tan, tanf, or tanl. Return NULL_TREE if no simplification can be made. */ static tree @@ -9046,10 +9070,7 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore) break; CASE_FLT_FN (BUILT_IN_COSH): - if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) - return do_mpfr_arg1 (TREE_VALUE (arglist), type, mpfr_cosh, - NULL, NULL, 0); - break; + return fold_builtin_cosh (arglist, type, fndecl); CASE_FLT_FN (BUILT_IN_TANH): if (validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) |