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
This commit is contained in:
Jan Hubicka 2000-03-29 09:54:31 +00:00 committed by Jan Hubicka
parent 402eec872f
commit db8cb48e64
6 changed files with 34 additions and 5 deletions

View File

@ -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.

View File

@ -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))

View File

@ -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. */

View File

@ -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

View File

@ -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

View File

@ -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;