diff options
Diffstat (limited to 'gcc')
| -rw-r--r-- | gcc/ChangeLog | 15 | ||||
| -rw-r--r-- | gcc/calls.c | 2 | ||||
| -rw-r--r-- | gcc/flags.h | 4 | ||||
| -rw-r--r-- | gcc/invoke.texi | 7 | ||||
| -rw-r--r-- | gcc/stmt.c | 2 | ||||
| -rw-r--r-- | gcc/toplev.c | 9 | 
6 files changed, 34 insertions, 5 deletions
| diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4faf2d3991f..226c83b40a2 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 07898c328d5..a978dd45321 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 1d7e782a361..81f5bda4c8b 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 51d21a10124..eb2696131d9 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 88d665e7236..f807554de15 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 028aad89d80..0b06ae2be8a 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; | 

