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
This commit is contained in:
parent
bbea461bd9
commit
85aef79f75
4 changed files with 53 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
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.
|
||||
|
||||
2006-12-14 Dorit Nuzman <dorit@il.ibm.com>
|
||||
Trevor Smigiel <trevor_smigiel@playstation.sony.com>
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2006-12-14 Richard Guenther <rguenther@suse.de>
|
||||
|
||||
PR tree-optimization/30198
|
||||
* gcc.dg/builtins-60.c: New testcase.
|
||||
|
||||
2006-12-14 Dorit Nuzman <dorit@il.ibm.com>
|
||||
|
||||
* lib/target-supports.exp (vect_no_align): Remove spu.
|
||||
|
|
16
gcc/testsuite/gcc.dg/builtins-60.c
Normal file
16
gcc/testsuite/gcc.dg/builtins-60.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-fdump-tree-gimple" } */
|
||||
|
||||
double test1 (double x)
|
||||
{
|
||||
return __real __builtin_cexpi (x);
|
||||
}
|
||||
|
||||
double test2 (double x)
|
||||
{
|
||||
return __imag __builtin_cexpi (x);
|
||||
}
|
||||
|
||||
/* { dg-final { scan-tree-dump "cos" "gimple" } } */
|
||||
/* { dg-final { scan-tree-dump "sin" "gimple" } } */
|
||||
/* { dg-final { cleanup-tree-dump "gimple" } } */
|
Loading…
Add table
Reference in a new issue