Patchwork decrease storage requirements for tree EXPRs

login
register
mail settings
Submitter Nathan Froyd
Date Nov. 24, 2010, 7:17 p.m.
Message ID <20101124191703.GD8544@codesourcery.com>
Download mbox | patch
Permalink /patch/72944/
State New
Headers show

Comments

Nathan Froyd - Nov. 24, 2010, 7:17 p.m.
struct tree_exp includes a `block' field, which, AFAICT, is only used
during expand to pass information from gimple stmts that contain the
block information down to the RTL level.  This is a waste of space, as
the relevant field is used only rarely and we pay for it throughout the
entire compilation.  (expand should be tweaked to do this differently,
but that'd be slightly more complicated than the below.)

Equally AFAICT, the TREE_CHAIN field is entirely unused in struct
tree_exp.  The patch below proposes to move the block information to
reside in this heretofore unused field and delete the `block' field,
thus making struct tree_exp one word smaller.  (Yes, I recognize the
humor in using TREE_CHAIN for *more* things.)  This saves ~1-2% of total
space in a typical compilation; I have not done any measurements on
whether it speeds up the compiler at all.

The patch has been bootstrapped on x86_64-linux-gnu with no ill effects.
I have run it through a full test run + the gdb testsuite; I do not have
the numbers in front of me at the moment (they're on a computer I don't
have access to right now), but I recall them looking good.

OK to commit?  Or would people rather see expand modified (probably in
stage1, rather than stage3)?

-Nathan

gcc/
	* tree.h (struct tree_exp): Delete block field.
	* tree.c (tree_block): Return t->common.chain for EXPRs.

gcc/lto/
	* lto.c (lto_fixup_tree): Don't fixup t->exp.block.
Diego Novillo - Nov. 24, 2010, 7:57 p.m.
On 11/24/10 14:17, Nathan Froyd wrote:

> gcc/
> 	* tree.h (struct tree_exp): Delete block field.
> 	* tree.c (tree_block): Return t->common.chain for EXPRs.
>
> gcc/lto/
> 	* lto.c (lto_fixup_tree): Don't fixup t->exp.block.

This looks innocent enough, and I'm OK with it given the space savings. 
  But I defer to our RMs for approval.

I would like to see the changes to expand for 4.7, though.


Diego.
Richard Guenther - Nov. 24, 2010, 8 p.m.
On Wed, Nov 24, 2010 at 8:57 PM, Diego Novillo <dnovillo@google.com> wrote:
> On 11/24/10 14:17, Nathan Froyd wrote:
>
>> gcc/
>>        * tree.h (struct tree_exp): Delete block field.
>>        * tree.c (tree_block): Return t->common.chain for EXPRs.
>>
>> gcc/lto/
>>        * lto.c (lto_fixup_tree): Don't fixup t->exp.block.
>
> This looks innocent enough, and I'm OK with it given the space savings.  But
> I defer to our RMs for approval.

The patch is ok.

> I would like to see the changes to expand for 4.7, though.

Me too.

Richard.

>
> Diego.
>

Patch

Index: gcc/tree.h
===================================================================
--- gcc/tree.h	(revision 167123)
+++ gcc/tree.h	(working copy)
@@ -1854,7 +1854,6 @@  enum omp_clause_default_kind
 struct GTY(()) tree_exp {
   struct tree_common common;
   location_t locus;
-  tree block;
   tree GTY ((special ("tree_exp"),
 	     desc ("TREE_CODE ((tree) &%0)")))
     operands[1];
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 167123)
+++ gcc/tree.c	(working copy)
@@ -10526,7 +10526,7 @@  tree_block (tree t)
   char const c = TREE_CODE_CLASS (TREE_CODE (t));
 
   if (IS_EXPR_CODE_CLASS (c))
-    return &t->exp.block;
+    return &TREE_CHAIN (t);
   gcc_unreachable ();
   return NULL;
 }
Index: gcc/lto/lto.c
===================================================================
--- gcc/lto/lto.c	(revision 167123)
+++ gcc/lto/lto.c	(working copy)
@@ -1932,7 +1932,6 @@  lto_fixup_tree (tree *tp, int *walk_subt
 	{
 	  /* walk_tree only handles TREE_OPERANDs. Do the rest here.  */
 	  lto_fixup_common (t, data);
-	  LTO_FIXUP_SUBTREE (t->exp.block);
 	  *walk_subtrees = 1;
 	}
       else