This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Speedup for tree-inline.c?


Hi,

With the attached patch we should walk_tree a bit faster when looking
for alloca and longjmp calls.  There doesn't seem to be any reason to
walk the same tree multiple times when looking for alloca and longjmp,
and in calls_setjmp_p (in cp/optimize.c), we also use
walk_tree_without_duplicates.

(I would expect to see a speedup from this, but I haven't been able to
test that yet, only with checking enabled, but that's a cheat because we
do fewer tree checks...).  

Another thing that could maybe speedup walk_tree a bit is to add a new
argument that tells whether or not you want to walk type nodes.  Again,
there really seems to be no reason to walk type nodes when you're
looking for a function call in a tree. I was thinking of something like,

 tail_recurse:
  /* Skip empty subtrees.  */
  if (!*tp
      || (TREE_CODE_CLASS (*tp) == 't' && !walk_type_nodes))
    return NULL_TREE;

where walk_type_nodes would be the new function argument to walk_tree. 
Anyone know if it is necessary to always walk type nodes?

Anyway, this patch first.  Bootstrapped all except Ada on
i586-pc-linux-gnu, regtesting well under way.  OK for mainline if it
passes?

Greetz
Steven

2003-04-23  Steven Bosscher  <steven at gcc dot gnu dot org>

	* tree-inline.c (find_alloca_call_1): Use conditional expr.
	(find_alloca_call): Use walk_tree_without_duplicates.
	(find_builtin_longjmp_call): Likewise.


Index: tree-inline.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-inline.c,v
retrieving revision 1.53
diff -c -3 -p -r1.53 tree-inline.c
*** tree-inline.c	10 Apr 2003 15:00:03 -0000	1.53
--- tree-inline.c	23 Apr 2003 21:27:41 -0000
*************** find_alloca_call_1 (tp, walk_subtrees, d
*** 890,898 ****
       int *walk_subtrees ATTRIBUTE_UNUSED;
       void *data ATTRIBUTE_UNUSED;
  {
!   if (alloca_call_p (*tp))
!     return *tp;
!   return NULL;
  }
  
  /* Return subexpression representing possible alloca call, if any.  */
--- 890,896 ----
       int *walk_subtrees ATTRIBUTE_UNUSED;
       void *data ATTRIBUTE_UNUSED;
  {
!   return alloca_call_p (*tp) ? *tp : NULL_TREE;
  }
  
  /* Return subexpression representing possible alloca call, if any.  */
*************** find_alloca_call (exp)
*** 902,908 ****
  {
    int line = lineno;
    const char *file = input_filename;
!   tree ret = walk_tree (&exp, find_alloca_call_1, NULL, NULL);
    lineno = line;
    input_filename = file;
    return ret;
--- 900,906 ----
  {
    int line = lineno;
    const char *file = input_filename;
!   tree ret = walk_tree_without_duplicates (&exp, find_alloca_call_1, NULL);
    lineno = line;
    input_filename = file;
    return ret;
*************** find_builtin_longjmp_call (exp)
*** 933,939 ****
  {
    int line = lineno;
    const char *file = input_filename;
!   tree ret = walk_tree (&exp, find_builtin_longjmp_call_1, NULL, NULL);
    lineno = line;
    input_filename = file;
    return ret;
--- 931,937 ----
  {
    int line = lineno;
    const char *file = input_filename;
!   tree ret = walk_tree_without_duplicates (&exp, find_builtin_longjmp_call_1, NULL);
    lineno = line;
    input_filename = file;
    return ret;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]