Save 6% of GGC memory (consumed in tree-ssa-pre)

Jan Hubicka jh@suse.cz
Tue Aug 1 12:19:00 GMT 2006


> Jan Hubicka wrote:
> > Hi,
> > memory statistics for combine.c at -O2 shows 13% of memory to be taken
> > by create_tree_ann function:
> > tree-phinodes.c:156 (allocate_phi_node)             3813160: 4.6% 0: 0.0%          0: 0.0%      22568: 0.3%      12114
> > genrtl.c:17 (gen_rtx_fmt_ee)                        7518920: 9.1% 0: 0.0%       3080: 0.0%    1504400:17.1%     188050
> > tree-dfa.c:209 (create_tree_ann)                   10927080:13.3% 0: 0.0%       7440: 0.1%     728968: 8.3%      91121
> > Total                                              82223861 12694004          6318427          8805836          1369076
> > 
> > This is the same for my now favorite testcase and other common sources.
> > I always accounted it to annotations being bloated, but I unstrumented
> > create_tree_ann for statistics and found out that this all memory is in
> > fact allocated all by tree-vn and it is all there just to hold one
> > pointer value_handle.  I would say that a hashtable would do a lot
> > better job here (or direct use of the annotation pointer on
> > expressions), but I am leaving it for Danny 
> 
> If you use a hashtable, your PRE times will jump about 4 or 5x (my
> recollection but feel free to try it yourself :) )
> It makes *very* heavy use of getting the value handle, and it can't
> really be avoided.
Hmm,
not sure if it is best way around, but this patch saves about 50% of the
allocated annotations on combine.c (4688760 instead of 10927080) and if
PRE is really so annotation heavy, it should also save some compilation
time (as would do inlining get_value_handle probably?).  What do you
think?

Honza

Index: tree-ssa-pre.c
===================================================================
--- tree-ssa-pre.c	(revision 115851)
+++ tree-ssa-pre.c	(working copy)
@@ -1151,7 +1151,7 @@
 		TREE_OPERAND (newexpr, 0) = newop0 == oldop0 ? oldop0 : get_value_handle (newop0);
 		TREE_OPERAND (newexpr, 1) = listchanged ? newarglist : oldarglist;
 		TREE_OPERAND (newexpr, 2) = newop2 == oldop2 ? oldop2 : get_value_handle (newop2);
-		create_tree_ann (newexpr);
+		newexpr->common.ann = (void *)1;
 		vn_lookup_or_add_with_vuses (newexpr, tvuses);
 		expr = newexpr;
 		phi_trans_add (oldexpr, newexpr, pred, tvuses);
@@ -1260,7 +1260,7 @@
 	      }
 	    else
 	      {
-		create_tree_ann (newexpr);
+		newexpr->common.ann = (void *)1;
 		vn_lookup_or_add_with_vuses (newexpr, newvuses);
 	      }
 	    expr = newexpr;
@@ -1302,7 +1302,7 @@
 	      }
 	    else
 	      {
-		create_tree_ann (newexpr);
+		newexpr->common.ann = (void *)1;
 		vn_lookup_or_add (newexpr, NULL);
 	      }
 	    expr = newexpr;
@@ -1335,7 +1335,7 @@
 	      }
 	    else
 	      {
-		create_tree_ann (newexpr);
+		newexpr->common.ann = (void *)1;
 		vn_lookup_or_add (newexpr, NULL);
 	      }
 	    expr = newexpr;
Index: tree-vn.c
===================================================================
--- tree-vn.c	(revision 115851)
+++ tree-vn.c	(working copy)
@@ -180,6 +180,8 @@
 {
   if (TREE_CODE (e) == SSA_NAME)
     SSA_NAME_VALUE (e) = v;
+  else if ((size_t)e->common.ann & 1)
+    e->common.ann = (void *)((size_t)v | 1);
   else if (EXPR_P (e) || DECL_P (e) || TREE_CODE (e) == TREE_LIST
 	   || TREE_CODE (e) == CONSTRUCTOR)
     get_tree_ann (e)->common.value_handle = v;
@@ -435,6 +437,8 @@
 
   if (TREE_CODE (expr) == SSA_NAME)
     return SSA_NAME_VALUE (expr);
+  else if ((size_t)expr->common.ann & 1)
+    return (void *)((size_t)expr->common.ann & ~(size_t)1);
   else if (EXPR_P (expr) || DECL_P (expr) || TREE_CODE (expr) == TREE_LIST
 	   || TREE_CODE (expr) == CONSTRUCTOR)
     {



More information about the Gcc-patches mailing list