diff options
author | Richard Guenther <rguenther@suse.de> | 2006-12-14 13:09:24 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-12-14 13:09:24 +0000 |
commit | 85aef79f75e6be8e8a8d7a1111f6110b98a609ca (patch) | |
tree | 664d4031f261d73571b0dab79f7caeb6cbda1f05 /gcc/fold-const.c | |
parent | bbea461bd91a323cd5e4d537c7362abc7fe591e2 (diff) | |
download | gcc-85aef79f75e6be8e8a8d7a1111f6110b98a609ca.zip gcc-85aef79f75e6be8e8a8d7a1111f6110b98a609ca.tar.gz gcc-85aef79f75e6be8e8a8d7a1111f6110b98a609ca.tar.bz2 |
re PR middle-end/30198 (__real / __imag cexpi (x) can be folded to cos (x) / sin (x))
2006-12-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/30198
* fold-const.c (fold_unary): Fold REALPART_EXPR of cexpi to cos.
Fold IMAGPART_EXPR of cexpi to sin.
* gcc.dg/builtins-60.c: New testcase.
From-SVN: r119858
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index da1bfed..751ef2e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7715,6 +7715,19 @@ fold_unary (enum tree_code code, tree type, tree op0) tem = fold_build1 (REALPART_EXPR, itype, TREE_OPERAND (arg0, 0)); return fold_convert (type, tem); } + if (TREE_CODE (arg0) == CALL_EXPR) + { + tree fn = get_callee_fndecl (arg0); + if (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL) + switch (DECL_FUNCTION_CODE (fn)) + { + CASE_FLT_FN (BUILT_IN_CEXPI): + fn = mathfn_built_in (type, BUILT_IN_COS); + return build_function_call_expr (fn, TREE_OPERAND (arg0, 1)); + + default:; + } + } return NULL_TREE; case IMAGPART_EXPR: @@ -7741,6 +7754,19 @@ fold_unary (enum tree_code code, tree type, tree op0) tem = fold_build1 (IMAGPART_EXPR, itype, TREE_OPERAND (arg0, 0)); return fold_convert (type, negate_expr (tem)); } + if (TREE_CODE (arg0) == CALL_EXPR) + { + tree fn = get_callee_fndecl (arg0); + if (DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL) + switch (DECL_FUNCTION_CODE (fn)) + { + CASE_FLT_FN (BUILT_IN_CEXPI): + fn = mathfn_built_in (type, BUILT_IN_SIN); + return build_function_call_expr (fn, TREE_OPERAND (arg0, 1)); + + default:; + } + } return NULL_TREE; default: |