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]

[C++ patch] Little speedup of for_each_template_parm_r


Hi,
this code saves roughtly 1 million out of 7 millions of calls of the
for_each_template_parm_r function on Gerald's testcase.  Why we need so
many at first place?  It seem to be major contributor to frontend times
on this testcase and seems to be getting even worse on larger DLV
testcases.

Bootstrapped/regtested i686-pc-gnu-linux (c/c++ only) OK?
Honza

2004-01-11  Jan Hubicka  <jh@suse.cz>
	* pt.c (for_each_template_parm): Do not check for duplicates.
	(for_each_template_parm): Use walk_tree duplicate checking code.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.809
diff -c -3 -p -r1.809 pt.c
*** cp/pt.c	8 Jan 2004 11:52:41 -0000	1.809
--- cp/pt.c	11 Jan 2004 20:03:21 -0000
*************** for_each_template_parm_r (tree* tp, int*
*** 4511,4527 ****
    struct pair_fn_data *pfd = (struct pair_fn_data *) d;
    tree_fn_t fn = pfd->fn;
    void *data = pfd->data;
-   void **slot;
- 
-   /* If we have already visited this tree, there's no need to walk
-      subtrees.  Otherwise, add it to the visited table.  */
-   slot = htab_find_slot (pfd->visited, *tp, INSERT);
-   if (*slot)
-     {
-       *walk_subtrees = 0;
-       return NULL_TREE;
-     }
-   *slot = *tp;
  
    if (TYPE_P (t)
        && for_each_template_parm (TYPE_CONTEXT (t), fn, data, pfd->visited))
--- 4511,4516 ----
*************** for_each_template_parm (tree t, tree_fn_
*** 4714,4720 ****
    result = walk_tree (&t, 
  		      for_each_template_parm_r, 
  		      &pfd,
! 		      NULL) != NULL_TREE;
  
    /* Clean up.  */
    if (!visited)
--- 4703,4709 ----
    result = walk_tree (&t, 
  		      for_each_template_parm_r, 
  		      &pfd,
! 		      pfd.visited) != NULL_TREE;
  
    /* Clean up.  */
    if (!visited)


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