aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>2006-11-18 20:29:22 +0000
committerKaveh Ghazi <ghazi@gcc.gnu.org>2006-11-18 20:29:22 +0000
commit6af46feb6b6cf1ff61860db3bc4af7d0ed03e148 (patch)
tree54f835b1efbe21c849bac39f9a546c2ce07db730 /gcc/fold-const.c
parent4f7d854795b86031099e9292e8b74d0791186898 (diff)
downloadgcc-6af46feb6b6cf1ff61860db3bc4af7d0ed03e148.zip
gcc-6af46feb6b6cf1ff61860db3bc4af7d0ed03e148.tar.gz
gcc-6af46feb6b6cf1ff61860db3bc4af7d0ed03e148.tar.bz2
fold-const.c (fold_strip_sign_ops): Handle copysign.
* fold-const.c (fold_strip_sign_ops): Handle copysign. testsuite: * gcc.dg/builtins-20.c: Add cases for copysign. From-SVN: r118975
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 143dcad..cd7f1d9 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -13388,14 +13388,29 @@ fold_strip_sign_ops (tree exp)
break;
case CALL_EXPR:
- /* Strip sign ops from the argument of "odd" math functions. */
- if (negate_mathfn_p (builtin_mathfn_code (exp)))
- {
- arg0 = fold_strip_sign_ops (TREE_VALUE (TREE_OPERAND (exp, 1)));
- if (arg0)
- return build_function_call_expr (get_callee_fndecl (exp),
- build_tree_list (NULL_TREE, arg0));
+ {
+ const enum built_in_function fcode = builtin_mathfn_code (exp);
+ switch (fcode)
+ {
+ CASE_FLT_FN (BUILT_IN_COPYSIGN):
+ /* Strip copysign function call, return the 1st argument. */
+ arg0 = TREE_VALUE (TREE_OPERAND (exp, 1));
+ arg1 = TREE_VALUE (TREE_CHAIN (TREE_OPERAND (exp, 1)));
+ return omit_one_operand (TREE_TYPE (exp), arg0, arg1);
+
+ default:
+ /* Strip sign ops from the argument of "odd" math functions. */
+ if (negate_mathfn_p (fcode))
+ {
+ arg0 = fold_strip_sign_ops (TREE_VALUE (TREE_OPERAND (exp, 1)));
+ if (arg0)
+ return build_function_call_expr (get_callee_fndecl (exp),
+ build_tree_list (NULL_TREE,
+ arg0));
+ }
+ break;
}
+ }
break;
default: