This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Re-use SSA_NAME expressions
- From: law at redhat dot com
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 20 Nov 2003 08:37:58 -0700
- Subject: Re: [tree-ssa] Re-use SSA_NAME expressions
- Reply-to: law at redhat dot com
In message <20031119225506.GB1138@redhat.com>, Richard Henderson writes:
>On Wed, Nov 19, 2003 at 01:07:56PM -0700, law@redhat.com wrote:
>> + /* Free list of SSA_NAMEs. This list is wiped at the end of each functio
>n
>> + after we leave SSA form. */
>> + static varray_type free_ssanames = NULL;
>
>A varray is truely wasteful here. I suggest instead:
>
> static GTY ((deletable (""))) tree free_ssanames;
>
>and chain the nodes via TREE_CHAIN.
>
>The deletable tag means that we'll zap the list if we GC in the middle
>of optimization some day. Ordinarily you wouldn't want one of these
>cached free nodes preventing a page from being freed, but that would
>also prevent you from re-using SSA numbers that were freed so it might
>not be best here.
Bootstrapped and regression tested and of course I verified that we continued
to re-use SSA_NAMES :-)
* tree-ssanames.c (free_ssanames): No longer a varray.
(init_ssanames, make_ssa_name, release_ssa_name): Corresponding
changes.
Index: tree-ssanames.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssanames.c,v
retrieving revision 1.1.2.2
diff -c -3 -p -r1.1.2.2 tree-ssanames.c
*** tree-ssanames.c 20 Nov 2003 11:52:19 -0000 1.1.2.2
--- tree-ssanames.c 20 Nov 2003 15:34:42 -0000
*************** unsigned int highest_ssa_version;
*** 61,68 ****
/* Free list of SSA_NAMEs. This list is wiped at the end of each function
after we leave SSA form. */
! static varray_type free_ssanames = NULL;
!
/* Version numbers with special meanings. We start allocating new version
numbers after the special ones. */
#define UNUSED_NAME_VERSION 0
--- 61,68 ----
/* Free list of SSA_NAMEs. This list is wiped at the end of each function
after we leave SSA form. */
! static GTY ((deletable (""))) tree free_ssanames;
!
/* Version numbers with special meanings. We start allocating new version
numbers after the special ones. */
#define UNUSED_NAME_VERSION 0
*************** void
*** 78,84 ****
init_ssanames (void)
{
highest_ssa_version = UNUSED_NAME_VERSION + 1;
! VARRAY_TREE_INIT (free_ssanames, 1, "Free List of SSA_NAME exprs");
}
/* Finalize management of SSA_NAMEs. */
--- 78,84 ----
init_ssanames (void)
{
highest_ssa_version = UNUSED_NAME_VERSION + 1;
! free_ssanames = NULL;
}
/* Finalize management of SSA_NAMEs. */
*************** make_ssa_name (tree var, tree stmt)
*** 121,132 ****
/* If our free list has an element, then use it. Also reuse the
SSA version number of the element on the free list which helps
keep sbitmaps and arrays sized HIGHEST_SSA_VERSION smaller. */
! if (VARRAY_ACTIVE_SIZE (free_ssanames) > 0)
{
unsigned int save_version;
! t = VARRAY_TOP_TREE (free_ssanames);
! VARRAY_POP (free_ssanames);
#ifdef GATHER_STATISTICS
ssa_name_nodes_reused++;
#endif
--- 121,132 ----
/* If our free list has an element, then use it. Also reuse the
SSA version number of the element on the free list which helps
keep sbitmaps and arrays sized HIGHEST_SSA_VERSION smaller. */
! if (free_ssanames)
{
unsigned int save_version;
! t = free_ssanames;
! free_ssanames = TREE_CHAIN (free_ssanames);
#ifdef GATHER_STATISTICS
ssa_name_nodes_reused++;
#endif
*************** release_ssa_name (tree var)
*** 170,175 ****
if (SSA_NAME_DEF_STMT (var) != NULL)
{
SSA_NAME_DEF_STMT (var) = NULL;
! VARRAY_PUSH_TREE (free_ssanames, var);
}
}
--- 170,176 ----
if (SSA_NAME_DEF_STMT (var) != NULL)
{
SSA_NAME_DEF_STMT (var) = NULL;
! TREE_CHAIN (var) = free_ssanames;
! free_ssanames = var;
}
}