This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFA] expand from SSA form (1/2)
Hi,
On Sun, 26 Apr 2009, Michael Matz wrote:
> > > + Â if (SA.values
> > > + Â Â Â && TREE_CODE (lhs) == SSA_NAME
> > > + Â Â Â && SA.values[SSA_NAME_VERSION (lhs)])
> > > + Â Â lhs = gimple_assign_rhs_to_tree (SA.values[SSA_NAME_VERSION (lhs)]);
> >
> > Do we really need the SA.values array here? It seems that
> > a bitmap would be enough, as the definition should be still
> > reachable via SSA_NAME_DEF_STMT (lhs). (Thanks Paolo
> > for noticing this)
>
> This should indeed be possible, but I want to do this as cleanup next
> week.
Like so. Already regstrapped without regressions on x86_64-linux.
Committed as r146837.
Ciao,
Michael.
--
* ssaexpand.h (struct ssaexpand): Member 'values' is a bitmap.
(get_gimple_for_ssa_name): Adjust, lookup using SSA_NAME_DEF_STMT.
* tree-ssa-live.h: (find_replaceable_exprs): Return a bitmap.
(dump_replaceable_exprs): Take a bitmap.
* cfgexpand.c (gimple_cond_pred_to_tree): Handle bitmap instead of
array.
(expand_gimple_basic_block): Likewise.
* tree-ssa-ter.c (struct temp_expr_table_d): Make
replaceable_expressions member a bitmap.
(free_temp_expr_table): Pass back and deal with bitmap, not gimple*.
(mark_replaceable): Likewise.
(find_replaceable_in_bb, dump_replaceable_exprs): Likewise.
* tree-outof-ssa.c (remove_ssa_form): 'values' is a bitmap.
Index: cfgexpand.c
===================================================================
--- cfgexpand.c (Revision 146817)
+++ cfgexpand.c (Arbeitskopie)
@@ -94,8 +94,8 @@ gimple_cond_pred_to_tree (gimple stmt)
tree lhs = gimple_cond_lhs (stmt);
if (SA.values
&& TREE_CODE (lhs) == SSA_NAME
- && SA.values[SSA_NAME_VERSION (lhs)])
- lhs = gimple_assign_rhs_to_tree (SA.values[SSA_NAME_VERSION (lhs)]);
+ && bitmap_bit_p (SA.values, SSA_NAME_VERSION (lhs)))
+ lhs = gimple_assign_rhs_to_tree (SSA_NAME_DEF_STMT (lhs));
return build2 (gimple_cond_code (stmt), boolean_type_node,
lhs, gimple_cond_rhs (stmt));
@@ -2078,7 +2078,8 @@ expand_gimple_basic_block (basic_block b
/* Ignore this stmt if it is in the list of
replaceable expressions. */
if (SA.values
- && SA.values[SSA_NAME_VERSION (DEF_FROM_PTR (def_p))])
+ && bitmap_bit_p (SA.values,
+ SSA_NAME_VERSION (DEF_FROM_PTR (def_p))))
continue;
}
stmt_tree = gimple_to_tree (stmt);
Index: tree-ssa-live.h
===================================================================
--- tree-ssa-live.h (Revision 146817)
+++ tree-ssa-live.h (Arbeitskopie)
@@ -340,8 +340,8 @@ extern var_map coalesce_ssa_name (void);
/* From tree-ssa-ter.c */
-extern gimple *find_replaceable_exprs (var_map);
-extern void dump_replaceable_exprs (FILE *, gimple *);
+extern bitmap find_replaceable_exprs (var_map);
+extern void dump_replaceable_exprs (FILE *, bitmap);
#endif /* _TREE_SSA_LIVE_H */
Index: tree-ssa-ter.c
===================================================================
--- tree-ssa-ter.c (Revision 146815)
+++ tree-ssa-ter.c (Arbeitskopie)
@@ -159,7 +159,7 @@ typedef struct temp_expr_table_d
{
var_map map;
bitmap *partition_dependencies; /* Partitions expr is dependent on. */
- gimple *replaceable_expressions; /* Replacement expression table. */
+ bitmap replaceable_expressions; /* Replacement expression table. */
bitmap *expr_decl_uids; /* Base uids of exprs. */
bitmap *kill_list; /* Expr's killed by a partition. */
int virtual_partition; /* Pseudo partition for virtual ops. */
@@ -216,10 +216,10 @@ new_temp_expr_table (var_map map)
/* Free TER table T. If there are valid replacements, return the expression
vector. */
-static gimple *
+static bitmap
free_temp_expr_table (temp_expr_table_p t)
{
- gimple *ret = NULL;
+ bitmap ret = NULL;
#ifdef ENABLE_CHECKING
unsigned x;
@@ -255,7 +255,7 @@ version_to_be_replaced_p (temp_expr_tabl
{
if (!tab->replaceable_expressions)
return false;
- return tab->replaceable_expressions[version] != NULL;
+ return bitmap_bit_p (tab->replaceable_expressions, version);
}
@@ -562,8 +562,8 @@ mark_replaceable (temp_expr_table_p tab,
/* Set the replaceable expression. */
if (!tab->replaceable_expressions)
- tab->replaceable_expressions = XCNEWVEC (gimple, num_ssa_names + 1);
- tab->replaceable_expressions[version] = SSA_NAME_DEF_STMT (var);
+ tab->replaceable_expressions = BITMAP_ALLOC (NULL);
+ bitmap_set_bit (tab->replaceable_expressions, version);
}
@@ -653,12 +653,12 @@ find_replaceable_in_bb (temp_expr_table_
NULL is returned by the function, otherwise an expression vector indexed
by SSA_NAME version numbers. */
-extern gimple *
+extern bitmap
find_replaceable_exprs (var_map map)
{
basic_block bb;
temp_expr_table_p table;
- gimple *ret;
+ bitmap ret;
table = new_temp_expr_table (map);
FOR_EACH_BB (bb)
@@ -676,19 +676,19 @@ find_replaceable_exprs (var_map map)
/* Dump TER expression table EXPR to file F. */
void
-dump_replaceable_exprs (FILE *f, gimple *expr)
+dump_replaceable_exprs (FILE *f, bitmap expr)
{
tree var;
unsigned x;
fprintf (f, "\nReplacing Expressions\n");
for (x = 0; x < num_ssa_names; x++)
- if (expr[x])
+ if (bitmap_bit_p (expr, x))
{
var = ssa_name (x);
print_generic_expr (f, var, TDF_SLIM);
fprintf (f, " replace with --> ");
- print_gimple_stmt (f, expr[x], 0, TDF_SLIM);
+ print_gimple_stmt (f, SSA_NAME_DEF_STMT (var), 0, TDF_SLIM);
fprintf (f, "\n");
}
fprintf (f, "\n");
Index: tree-outof-ssa.c
===================================================================
--- tree-outof-ssa.c (Revision 146817)
+++ tree-outof-ssa.c (Arbeitskopie)
@@ -791,7 +791,7 @@ expand_phi_nodes (struct ssaexpand *sa)
static void
remove_ssa_form (bool perform_ter, struct ssaexpand *sa)
{
- gimple *values = NULL;
+ bitmap values = NULL;
var_map map;
unsigned i;
@@ -926,7 +926,7 @@ finish_out_of_ssa (struct ssaexpand *sa)
{
free (sa->partition_to_pseudo);
if (sa->values)
- free (sa->values);
+ BITMAP_FREE (sa->values);
delete_var_map (sa->map);
BITMAP_FREE (sa->partition_has_default_def);
memset (sa, 0, sizeof *sa);
Index: ssaexpand.h
===================================================================
--- ssaexpand.h (Revision 146817)
+++ ssaexpand.h (Arbeitskopie)
@@ -31,10 +31,9 @@ struct ssaexpand
/* The computed partitions of SSA names are stored here. */
var_map map;
- /* For a SSA name version V values[V] contains the gimple statement
- defining it iff TER decided that it should be forwarded, NULL
- otherwise. */
- gimple *values;
+ /* For an SSA name version V bit V is set iff TER decided that
+ its definition should be forwarded. */
+ bitmap values;
/* For a partition number I partition_to_pseudo[I] contains the
RTL expression of the allocated space of it (either a MEM or
@@ -67,8 +66,8 @@ static inline gimple
get_gimple_for_ssa_name (tree exp)
{
int v = SSA_NAME_VERSION (exp);
- if (SA.values)
- return SA.values[v];
+ if (SA.values && bitmap_bit_p (SA.values, v))
+ return SSA_NAME_DEF_STMT (exp);
return NULL;
}