This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix -fno-optimize-sibling-calls breakage
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 23 Apr 2006 20:19:35 +0200
- Subject: Fix -fno-optimize-sibling-calls breakage
The doc are pretty clear:
`-foptimize-sibling-calls'
Optimize sibling and tail recursive calls.
Enabled at levels `-O2', `-O3', `-Os'.
that is to say, -foptimize-sibling-calls controls the tail recursive call
optimization too.
Tested on x86_64-suse-linux, applied to all active branches as obvious.
2006-04-23 Eric Botcazou <ebotcazou@adacore.com>
* tree-tailcall.c (pass_tail_recursion): Use gate_tail_calls too.
2006-04-23 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/sibcall-7.c: New test.
* gcc.dg/tree-ssa/tailrecursion-1.c: Pass -foptimize-sibling-calls.
* gcc.dg/tree-ssa/tailrecursion-2.c: Likewise.
* gcc.dg/tree-ssa/tailrecursion-3.c: Likewise.
* gcc.dg/tree-ssa/tailrecursion-4.c: Likewise.
* gcc.dg/tree-ssa/tailrecursion-5.c: Likewise.
--
Eric Botcazou
/* Simple check that tail recursive call optimization is also
controlled by -foptimize-sibling-calls.
Copyright (C) 2006 Free Software Foundation Inc.
Original test by Hans-Peter Nilsson <hp@bitrange.com> */
/* { dg-do run } */
/* { dg-options "-O2 -fno-optimize-sibling-calls" } */
extern void abort (void);
extern void recurser_void (int);
extern void track (int);
int main (void)
{
recurser_void (0);
return 0;
}
void recurser_void (int n)
{
if (n == 0 || n == 7)
track (n);
if (n == 10)
return;
recurser_void (n + 1);
}
void *trackpoint;
void track (int n)
{
char stackpos[1];
if (n == 0)
trackpoint = stackpos;
else if (n != 7 || trackpoint == stackpos)
abort ();
}
Index: tree-tailcall.c
===================================================================
--- tree-tailcall.c (revision 113067)
+++ tree-tailcall.c (working copy)
@@ -1017,7 +1017,7 @@ execute_tail_calls (void)
struct tree_opt_pass pass_tail_recursion =
{
"tailr", /* name */
- NULL, /* gate */
+ gate_tail_calls, /* gate */
execute_tail_recursion, /* execute */
NULL, /* sub */
NULL, /* next */
Index: testsuite/gcc.dg/tree-ssa/tailrecursion-4.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/tailrecursion-4.c (revision 113067)
+++ testsuite/gcc.dg/tree-ssa/tailrecursion-4.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-tailr-details" } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-tailr-details" } */
int
t(int a)
{
Index: testsuite/gcc.dg/tree-ssa/tailrecursion-5.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/tailrecursion-5.c (revision 113067)
+++ testsuite/gcc.dg/tree-ssa/tailrecursion-5.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do run } */
-/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-optimized" } */
extern void abort (void);
extern void exit (int);
Index: testsuite/gcc.dg/tree-ssa/tailrecursion-1.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/tailrecursion-1.c (revision 113067)
+++ testsuite/gcc.dg/tree-ssa/tailrecursion-1.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-tailr-details" } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-tailr-details" } */
int
t(int a)
{
Index: testsuite/gcc.dg/tree-ssa/tailrecursion-2.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/tailrecursion-2.c (revision 113067)
+++ testsuite/gcc.dg/tree-ssa/tailrecursion-2.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-tailr-details" } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-tailr-details" } */
int
t(char *a)
{
Index: testsuite/gcc.dg/tree-ssa/tailrecursion-3.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/tailrecursion-3.c (revision 113067)
+++ testsuite/gcc.dg/tree-ssa/tailrecursion-3.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O1 -fdump-tree-tailr-details" } */
+/* { dg-options "-O1 -foptimize-sibling-calls -fdump-tree-tailr-details" } */
int
t(int a)
{