This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[dataflow] less useless work/memory on bb's without artificial defs/uses
- From: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 30 Mar 2007 14:00:13 +0200
- Subject: [dataflow] less useless work/memory on bb's without artificial defs/uses
- Reply-to: bonzini at gnu dot org
If there is no artificial def or use in the basic block,
DF already avoids creating bitmaps for no use. However,
it does keep "in" and "top" bitmaps separate, which is
useless and consumes memory.
This patch allows "in" and "top" pointers to share the
same bitmap.
Bootstrapped/regtested i686-pc-linux-gnu, I don't know
exactly how much it saves but I guess some 0.5%.
Ok?
Paolo
2007-03-30 Paolo Bonzini <bonzini@gnu.org>
* dce.c (dce_process_block): Copy into DF_LR_IN.
* df-problems.c (df_lr_free_bb_info): Support bb_info->in
being the same bitmap as bb_info->top.
(df_lr_alloc): The adef and ause fields must be either
both NULL or both non-NULL. Initialize bb_info->top
to bb_info->in.
(df_lr_bb_local_compute): Allocate adef, ause, top together.
(df_lr_transfer_function): Simplify according to above
assumptions.
(df_lr_free): Zero out bb_info->top instead of freeing it
if it is the same as bb_info->in.
Index: dce.c
===================================================================
--- dce.c (revision 123155)
+++ dce.c (working copy)
@@ -611,12 +611,10 @@ dce_process_block (basic_block bb, bool
#ifdef ENABLE_CHECKING
gcc_assert (insns_deleted);
#endif
- BITMAP_FREE (DF_LR_IN (bb));
- DF_LR_IN (bb) = local_live;
+ bitmap_copy (DF_LR_IN (bb), local_live);
}
- else
- BITMAP_FREE (local_live);
+ BITMAP_FREE (local_live);
return block_changed;
}
Index: df-problems.c
===================================================================
--- df-problems.c (revision 123293)
+++ df-problems.c (working copy)
@@ -1348,14 +1348,16 @@ df_lr_free_bb_info (basic_block bb ATTRI
{
BITMAP_FREE (bb_info->use);
BITMAP_FREE (bb_info->def);
+ if (bb_info->in == bb_info->top)
+ bb_info->top = NULL;
+ else
+ {
+ BITMAP_FREE (bb_info->top);
+ BITMAP_FREE (bb_info->ause);
+ BITMAP_FREE (bb_info->adef);
+ }
BITMAP_FREE (bb_info->in);
BITMAP_FREE (bb_info->out);
- BITMAP_FREE (bb_info->top);
- if (bb_info->ause)
- BITMAP_FREE (bb_info->ause);
- if (bb_info->adef)
- BITMAP_FREE (bb_info->adef);
-
pool_free (df_lr->block_pool, bb_info);
}
}
@@ -1384,9 +1386,10 @@ df_lr_alloc (bitmap all_blocks ATTRIBUTE
bitmap_clear (bb_info->def);
bitmap_clear (bb_info->use);
if (bb_info->adef)
- bitmap_clear (bb_info->adef);
- if (bb_info->ause)
- bitmap_clear (bb_info->ause);
+ {
+ bitmap_clear (bb_info->adef);
+ bitmap_clear (bb_info->ause);
+ }
}
else
{
@@ -1396,7 +1399,7 @@ df_lr_alloc (bitmap all_blocks ATTRIBUTE
bb_info->def = BITMAP_ALLOC (NULL);
bb_info->in = BITMAP_ALLOC (NULL);
bb_info->out = BITMAP_ALLOC (NULL);
- bb_info->top = BITMAP_ALLOC (NULL);
+ bb_info->top = bb_info->in;
bb_info->adef = NULL;
bb_info->ause = NULL;
}
@@ -1529,9 +1532,13 @@ df_lr_bb_local_compute (unsigned int bb_
{
unsigned int dregno = DF_REF_REGNO (def);
if (bb_info->adef == NULL)
- bb_info->adef = BITMAP_ALLOC (NULL);
- if (bb_info->ause == NULL)
- bb_info->ause = BITMAP_ALLOC (NULL);
+ {
+ gcc_assert (bb_info->ause == NULL);
+ gcc_assert (bb_info->top == bb_info->in);
+ bb_info->adef = BITMAP_ALLOC (NULL);
+ bb_info->ause = BITMAP_ALLOC (NULL);
+ bb_info->top = BITMAP_ALLOC (NULL);
+ }
bitmap_set_bit (bb_info->adef, dregno);
}
}
@@ -1545,9 +1552,13 @@ df_lr_bb_local_compute (unsigned int bb_
if (DF_REF_FLAGS (use) & DF_REF_AT_TOP)
{
if (bb_info->adef == NULL)
- bb_info->adef = BITMAP_ALLOC (NULL);
- if (bb_info->ause == NULL)
- bb_info->ause = BITMAP_ALLOC (NULL);
+ {
+ gcc_assert (bb_info->ause == NULL);
+ gcc_assert (bb_info->top == bb_info->in);
+ bb_info->adef = BITMAP_ALLOC (NULL);
+ bb_info->ause = BITMAP_ALLOC (NULL);
+ bb_info->top = BITMAP_ALLOC (NULL);
+ }
bitmap_set_bit (bb_info->ause, DF_REF_REGNO (use));
}
}
@@ -1670,15 +1681,16 @@ df_lr_transfer_function (int bb_index)
bitmap top = bb_info->top;
bitmap ause = bb_info->ause;
bitmap adef = bb_info->adef;
+ bool changed;
+
+ changed = bitmap_ior_and_compl (top, use, out, def);
+ if (in != top)
+ {
+ gcc_assert (ause && adef);
+ changed |= bitmap_ior_and_compl (in, ause, top, adef);
+ }
- bitmap_ior_and_compl (top, use, out, def);
- if (ause && adef)
- return bitmap_ior_and_compl (in, ause, top, adef);
-
- if (bitmap_equal_p (in, top))
- return 0;
- bitmap_copy (in, top);
- return 1;
+ return changed;
}
@@ -1722,13 +1734,16 @@ df_lr_free (void)
{
BITMAP_FREE (bb_info->use);
BITMAP_FREE (bb_info->def);
+ if (bb_info->in == bb_info->top)
+ bb_info->top = NULL;
+ else
+ {
+ BITMAP_FREE (bb_info->top);
+ BITMAP_FREE (bb_info->ause);
+ BITMAP_FREE (bb_info->adef);
+ }
BITMAP_FREE (bb_info->in);
BITMAP_FREE (bb_info->out);
- BITMAP_FREE (bb_info->top);
- if (bb_info->ause)
- BITMAP_FREE (bb_info->ause);
- if (bb_info->adef)
- BITMAP_FREE (bb_info->adef);
}
}
free_alloc_pool (df_lr->block_pool);