More tail recursion infrastructure

Jeffrey A Law law@cygnus.com
Sun Jan 24 07:26:00 GMT 1999


Tail recursion and tail call sites inside loops are rare, and the mechanism
we use to build and store several call squences, then select one later
wrecks havoc with stmt.c's code to optimize loop exit tests.  So we just
don't try to perform tail recursion or tail call optimizations while we're
expanding a loop.

This patch exports a function from stmt.c which calls.c can query to find
out if we're expanding a loop.


	* stmt.c (stmt_loop_nest_empty): New function.
	* tree.h (stmt_loop_nest_empty): Declare it.

Index: tree.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/tree.h,v
retrieving revision 1.174
diff -c -3 -p -r1.174 tree.h
*** tree.h	1999/01/15 07:57:59	1.174
--- tree.h	1999/01/24 15:20:27
*************** extern int pushcase_range			PROTO((tree,
*** 1956,1961 ****
--- 1956,1962 ----
  						       tree (*) (tree, tree),
  						       tree, tree *));
  extern void using_eh_for_cleanups		PROTO((void));
+ extern int stmt_loop_nest_empty			PROTO((void));
  
  /* In fold-const.c */
  
Index: stmt.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/stmt.c,v
retrieving revision 1.159
diff -c -3 -p -r1.159 stmt.c
*** stmt.c	1999/01/20 17:50:26	1.159
--- stmt.c	1999/01/24 15:20:34
*************** expand_exit_loop_if_false (whichloop, co
*** 2311,2316 ****
--- 2311,2324 ----
    return 1;
  }
  
+ /* Return nonzero if the loop nest is empty.  Else return zero.  */
+ 
+ int
+ stmt_loop_nest_empty ()
+ {
+   return (loop_stack == NULL);
+ }
+ 
  /* Return non-zero if we should preserve sub-expressions as separate
     pseudos.  We never do so if we aren't optimizing.  We always do so
     if -fexpensive-optimizations.





More information about the Gcc-patches mailing list