aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2000-03-29 09:54:31 +0000
committerJan Hubicka <hubicka@gcc.gnu.org>2000-03-29 09:54:31 +0000
commitdb8cb48e64684efc2956b1229e9b1fbac558229a (patch)
tree6115adcb32b8d779e6fc736f4b16ea206907a22e
parent402eec872f73eebdbfb05cf4bbb133ed9af3460a (diff)
downloadgcc-db8cb48e64684efc2956b1229e9b1fbac558229a.zip
gcc-db8cb48e64684efc2956b1229e9b1fbac558229a.tar.gz
gcc-db8cb48e64684efc2956b1229e9b1fbac558229a.tar.bz2
flags.h (flag_optimize_sibling_calls): Declare.
* flags.h (flag_optimize_sibling_calls): Declare. * calls.c (expand_call): Fail sibcall when !flag_optimize_sibling_calls * invoke.texi (flag_optimize_sibling_calls): Document. * toplev.c (flag_optimize_sibling_calls): New global variable. (f_options): Add flag_optimize_sibling_calls. (rest_of_compilation): Conditionize optimize_sibling_and_tail_recursive_calls by flag_optimize_sibling_calls. (main): Set flag_optimize_sibling_calls for -O2. * stmt.c (expand_return): Conditionize tail recursion by flag_optimize_sibling_calls. From-SVN: r32802
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/calls.c2
-rw-r--r--gcc/flags.h4
-rw-r--r--gcc/invoke.texi7
-rw-r--r--gcc/stmt.c2
-rw-r--r--gcc/toplev.c9
6 files changed, 34 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4faf2d3..226c83b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+Wed Mar 29 11:51:13 MET DST 2000 Jan Hubicka <jh@suse.cz>
+
+ * flags.h (flag_optimize_sibling_calls): Declare.
+ * calls.c (expand_call): Fail sibcall when
+ !flag_optimize_sibling_calls
+ * invoke.texi (flag_optimize_sibling_calls): Document.
+ * toplev.c (flag_optimize_sibling_calls): New global variable.
+ (f_options): Add flag_optimize_sibling_calls.
+ (rest_of_compilation): Conditionize
+ optimize_sibling_and_tail_recursive_calls by
+ flag_optimize_sibling_calls.
+ (main): Set flag_optimize_sibling_calls for -O2.
+ * stmt.c (expand_return): Conditionize tail recursion by
+ flag_optimize_sibling_calls.
+
2000-03-29 Richard Henderson <rth@cygnus.com>
* config/i386/att.h (LOCAL_LABEL_PREFIX): Define.
diff --git a/gcc/calls.c b/gcc/calls.c
index 07898c3..a978dd4 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2034,7 +2034,7 @@ expand_call (exp, target, ignore)
the call. */
try_tail_call = 0;
- if (optimize >= 2
+ if (flag_optimize_sibling_calls
&& currently_expanding_call == 1
&& stmt_loop_nest_empty ()
&& ! any_pending_cleanups (1))
diff --git a/gcc/flags.h b/gcc/flags.h
index 1d7e782..81f5bda 100644
--- a/gcc/flags.h
+++ b/gcc/flags.h
@@ -299,6 +299,10 @@ extern int flag_volatile_static;
extern int flag_fast_math;
+/* Nonzero allows GCC to optimize sibling and tail recursive calls. */
+
+extern int flag_optimize_sibling_calls;
+
/* Nonzero means the front end generally wants `errno' maintained by math
operations, like built-in SQRT, unless overridden by flag_fast_math. */
diff --git a/gcc/invoke.texi b/gcc/invoke.texi
index 51d21a1..eb26961 100644
--- a/gcc/invoke.texi
+++ b/gcc/invoke.texi
@@ -164,8 +164,8 @@ in the following sections.
-finline-functions -finline-limit=@var{n} -fkeep-inline-functions
-fmove-all-movables -fno-default-inline -fno-defer-pop
-fno-function-cse -fno-inline -fno-peephole
--fomit-frame-pointer -foptimize-register-moves -fregmove
--frerun-cse-after-loop -frerun-loop-opt -freduce-all-givs
+-fomit-frame-pointer -foptimize-register-moves -foptimize-sibling-calls
+-fregmove -frerun-cse-after-loop -frerun-loop-opt -freduce-all-givs
-fschedule-insns -fschedule-insns2 -fstrength-reduce
-fstrict-aliasing -fthread-jumps -funroll-all-loops
-funroll-loops
@@ -2461,6 +2461,9 @@ restore frame pointers; it also makes an extra register available
in many functions. @strong{It also makes debugging impossible on
some machines.}
+@item -foptimize-sibling-calls
+Optimize sibling and tail recursive calls.
+
@ifset INTERNALS
On some machines, such as the Vax, this flag has no effect, because
the standard calling sequence automatically handles the frame pointer
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 88d665e..f807554 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2872,7 +2872,7 @@ expand_return (retval)
}
/* Attempt to optimize the call if it is tail recursive. */
- if (optimize
+ if (flag_optimize_sibling_calls
&& retval_rhs != NULL_TREE
&& frame_offset == 0
&& TREE_CODE (retval_rhs) == CALL_EXPR
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 028aad8..0b06ae2 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -519,6 +519,10 @@ int flag_no_peephole = 0;
int flag_fast_math = 0;
+/* Nonzero allows GCC to optimize sibling and tail recursive calls. */
+
+int flag_optimize_sibling_calls = 0;
+
/* Nonzero means the front end generally wants `errno' maintained by math
operations, like built-in SQRT, unless overridden by flag_fast_math. */
@@ -863,6 +867,8 @@ lang_independent_options f_options[] =
"Defer popping functions args from stack until later" },
{"omit-frame-pointer", &flag_omit_frame_pointer, 1,
"When possible do not generate stack frames"},
+ {"optimize-sibling-calls", &flag_optimize_sibling_calls, 1,
+ "Optimize sibling and tail recursive calls" },
{"cse-follow-jumps", &flag_cse_follow_jumps, 1,
"When running CSE, follow jumps to their targets" },
{"cse-skip-blocks", &flag_cse_skip_blocks, 1,
@@ -2991,7 +2997,7 @@ rest_of_compilation (decl)
/* We may have potential sibling or tail recursion sites. Select one
(of possibly multiple) methods of performing the call. */
init_EXPR_INSN_LIST_cache ();
- if (optimize)
+ if (flag_optimize_sibling_calls)
optimize_sibling_and_tail_recursive_calls ();
if (ggc_p)
@@ -4733,6 +4739,7 @@ main (argc, argv)
if (optimize >= 2)
{
+ flag_optimize_sibling_calls = 1;
flag_cse_follow_jumps = 1;
flag_cse_skip_blocks = 1;
flag_gcse = 1;