From d9b8d8568166fa8e96947bfa6c0c242d30e05253 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 8 Oct 2004 15:09:16 +0000 Subject: .: * tree-tailcall.c (tree_optimize_tail_calls_1): Use fold_convert, reverting my 2004-09-07 patch to use build_int_cst. testsuite: * gcc.c-torture/compile/acc1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88759 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 8 ++++++-- gcc/testsuite/gcc.c-torture/compile/acc1.c | 21 +++++++++++++++++++++ gcc/tree-tailcall.c | 12 ++++++++++-- 4 files changed, 42 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/acc1.c (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 161ead26267..1da3715b99e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2004-10-08 Nathan Sidwell + + * tree-tailcall.c (tree_optimize_tail_calls_1): Use fold_convert, + reverting my 2004-09-07 patch to use build_int_cst. + 2004-10-08 Eric Botcazou PR target/17245 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e83378b7e89..d16487d2e0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-10-08 Nathan Sidwell + + * gcc.c-torture/compile/acc1.c: New. + 2004-10-08 Andrew Pinski * gcc.dg/darwin-longdouble.c: Include stdlib.h and string.h. @@ -22329,7 +22333,7 @@ Thu Apr 27 15:58:18 MET DST 2000 Jan Hubicka * gcc.c-torture/compile/labels-2.c: New test. -1999-12-27 Martin von Löwis +1999-12-27 Martin von Löwis * gcc.c-torture/execute/991227-1.c: New test. @@ -22337,7 +22341,7 @@ Thu Apr 27 15:58:18 MET DST 2000 Jan Hubicka * g++.old-deja/g++.pt/instantiate6.C: Remove excess errors XFAIL. -1999-12-21 Martin von Löwis +1999-12-21 Martin von Löwis * gcc.c-torture/execute/991221-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/compile/acc1.c b/gcc/testsuite/gcc.c-torture/compile/acc1.c new file mode 100644 index 00000000000..206d16b8ce8 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/acc1.c @@ -0,0 +1,21 @@ +/* { dg-options "-O2 -ffast-math" } */ + +/* Fast maths allows tail recursion to be turned into iteration. */ + +double +foo (int n, double f) +{ + if (n == 0) + return f; + else + return f + foo (n - 1, f); +} + +double +bar (int n, double f) +{ + if (n == 0) + return f; + else + return f * bar (n - 1, f); +} diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 158a2d1d6fb..34ac8ee5834 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -896,7 +896,11 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) add_referenced_tmp_var (tmp); phi = create_phi_node (tmp, first); - add_phi_arg (&phi, build_int_cst (ret_type, 0), EDGE_PRED (first, 0)); + add_phi_arg (&phi, + /* RET_TYPE can be a float when -ffast-maths is + enabled. */ + fold_convert (ret_type, integer_zero_node), + EDGE_PRED (first, 0)); a_acc = PHI_RESULT (phi); } @@ -908,7 +912,11 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) add_referenced_tmp_var (tmp); phi = create_phi_node (tmp, first); - add_phi_arg (&phi, build_int_cst (ret_type, 1), EDGE_PRED (first, 0)); + add_phi_arg (&phi, + /* RET_TYPE can be a float when -ffast-maths is + enabled. */ + fold_convert (ret_type, integer_one_node), + EDGE_PRED (first, 0)); m_acc = PHI_RESULT (phi); } } -- cgit v1.2.1