aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/Makefile.in4
-rw-r--r--gcc/tree-sra.c68
3 files changed, 80 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e216ec1..86be13e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+2009-06-18 Martin Jambor <mjambor@suse.cz>
+
+ * tree-sra.c: Include statistics.h
+ (sra_stats): New variable.
+ (sra_initialize): Clear sra_stats.
+ (create_access_replacement): Increment sra_stats.replacements.
+ (get_access_replacement): Do not return twice.
+ (analyze_all_variable_accesses): Increment statistics counter by the
+ number of scalarized aggregates.
+ (generate_subtree_copies): Increment sra_stats.subtree_copies.
+ (sra_modify_expr): Increment sra_stats.exprs.
+ (load_assign_lhs_subreplacements): Increment sra_stats.subreplacements.
+ (sra_modify_assign): Increment sra_stats.exprs,
+ sra_stats.separate_lhs_rhs_handling and sra_stats.deleted.
+ (perform_intra_sra): Update statistics counters.
+ * Makefile.in (tree-sra.o): Add statistics.h to dependencies.
+
2009-06-18 Sandra Loosemore <sandra@codesourcery.com>
* config/arm/arm.c (TARGET_SCALAR_MODE_SUPPORTED_P): Redefine.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d5a4f36..744dab2 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2773,8 +2773,8 @@ tree-ssa-ccp.o : tree-ssa-ccp.c $(TREE_FLOW_H) $(CONFIG_H) \
$(TREE_DUMP_H) $(BASIC_BLOCK_H) $(TREE_PASS_H) langhooks.h \
tree-ssa-propagate.h value-prof.h $(FLAGS_H) $(TARGET_H) $(TOPLEV_H)
tree-sra.o : tree-sra.c $(CONFIG_H) $(SYSTEM_H) coretypes.h alloc-pool.h \
- $(TM_H) $(TREE_H) $(GIMPLE_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_DUMP_H) \
- $(TIMEVAR_H) $(PARAMS_H) $(TARGET_H) $(FLAGS_H)
+ $(TM_H) $(TREE_H) $(GIMPLE_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) statistics.h \
+ $(TREE_DUMP_H) $(TIMEVAR_H) $(PARAMS_H) $(TARGET_H) $(FLAGS_H)
tree-switch-conversion.o : tree-switch-conversion.c $(CONFIG_H) $(SYSTEM_H) \
$(TREE_H) $(TM_P_H) $(TREE_FLOW_H) $(DIAGNOSTIC_H) $(TREE_INLINE_H) \
$(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) $(GIMPLE_H) \
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index a2f783a..497b47b 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -80,6 +80,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple.h"
#include "tree-flow.h"
#include "diagnostic.h"
+#include "statistics.h"
#include "tree-dump.h"
#include "timevar.h"
#include "params.h"
@@ -219,6 +220,33 @@ static struct access *work_queue_head;
representative fields are dumped, otherwise those which only describe the
individual access are. */
+static struct
+{
+ /* Number of created scalar replacements. */
+ int replacements;
+
+ /* Number of times sra_modify_expr or sra_modify_assign themselves changed an
+ expression. */
+ int exprs;
+
+ /* Number of statements created by generate_subtree_copies. */
+ int subtree_copies;
+
+ /* Number of statements created by load_assign_lhs_subreplacements. */
+ int subreplacements;
+
+ /* Number of times sra_modify_assign has deleted a statement. */
+ int deleted;
+
+ /* Number of times sra_modify_assign has to deal with subaccesses of LHS and
+ RHS reparately due to type conversions or nonexistent matching
+ references. */
+ int separate_lhs_rhs_handling;
+
+ /* Number of processed aggregates is readily available in
+ analyze_all_variable_accesses and so is not stored here. */
+} sra_stats;
+
static void
dump_access (FILE *f, struct access *access, bool grp)
{
@@ -435,6 +463,7 @@ sra_initialize (void)
access_pool = create_alloc_pool ("SRA accesses", sizeof (struct access), 16);
link_pool = create_alloc_pool ("SRA links", sizeof (struct assign_link), 16);
base_access_vec = pointer_map_create ();
+ memset (&sra_stats, 0, sizeof (sra_stats));
}
/* Hook fed to pointer_map_traverse, deallocate stored vectors. */
@@ -1275,6 +1304,7 @@ create_access_replacement (struct access *access)
print_generic_expr (dump_file, repl, 0);
fprintf (dump_file, "\n");
}
+ sra_stats.replacements++;
return repl;
}
@@ -1286,10 +1316,8 @@ get_access_replacement (struct access *access)
{
gcc_assert (access->grp_to_be_replaced);
- if (access->replacement_decl)
- return access->replacement_decl;
-
- access->replacement_decl = create_access_replacement (access);
+ if (!access->replacement_decl)
+ access->replacement_decl = create_access_replacement (access);
return access->replacement_decl;
}
@@ -1597,7 +1625,7 @@ analyze_all_variable_accesses (void)
{
tree var;
referenced_var_iterator rvi;
- bool res = false;
+ int res = 0;
FOR_EACH_REFERENCED_VAR (var, rvi)
if (bitmap_bit_p (candidate_bitmap, DECL_UID (var)))
@@ -1621,7 +1649,7 @@ analyze_all_variable_accesses (void)
if (analyze_access_trees (access))
{
- res = true;
+ res++;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "\nAccess trees for ");
@@ -1635,7 +1663,13 @@ analyze_all_variable_accesses (void)
disqualify_candidate (var, "No scalar replacements to be created.");
}
- return res;
+ if (res)
+ {
+ statistics_counter_event (cfun, "Scalarized aggregates", res);
+ return true;
+ }
+ else
+ return false;
}
/* Return true iff a reference statement into aggregate AGG can be built for
@@ -1726,6 +1760,7 @@ generate_subtree_copies (struct access *access, tree agg,
insert_after ? GSI_NEW_STMT
: GSI_SAME_STMT);
stmt = gimple_build_assign (expr, repl);
+ sra_stats.subtree_copies++;
}
if (insert_after)
@@ -1862,6 +1897,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, bool write,
gcc_assert (useless_type_conversion_p (type, access->type));
*expr = repl;
}
+ sra_stats.exprs++;
}
if (access->first_child)
@@ -1956,6 +1992,7 @@ load_assign_lhs_subreplacements (struct access *lacc, struct access *top_racc,
stmt = gimple_build_assign (get_access_replacement (lacc), rhs);
gsi_insert_after (new_gsi, stmt, GSI_NEW_STMT);
update_stmt (stmt);
+ sra_stats.subreplacements++;
}
else if (lacc->grp_read && !lacc->grp_covered && !*refreshed)
{
@@ -2059,6 +2096,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
modify_this_stmt = true;
if (lacc->grp_partial_lhs)
force_gimple_rhs = true;
+ sra_stats.exprs++;
}
if (racc && racc->grp_to_be_replaced)
@@ -2067,6 +2105,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
modify_this_stmt = true;
if (racc->grp_partial_lhs)
force_gimple_rhs = true;
+ sra_stats.exprs++;
}
if (modify_this_stmt)
@@ -2158,6 +2197,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
if (access_has_children_p (lacc))
generate_subtree_copies (lacc->first_child, lacc->base, 0, 0, 0,
gsi, true, true);
+ sra_stats.separate_lhs_rhs_handling++;
}
else
{
@@ -2184,6 +2224,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
unlink_stmt_vdef (*stmt);
gsi_remove (&orig_gsi, true);
+ sra_stats.deleted++;
return SRA_SA_REMOVED;
}
}
@@ -2199,6 +2240,7 @@ sra_modify_assign (gimple *stmt, gimple_stmt_iterator *gsi,
gcc_assert (*stmt == gsi_stmt (*gsi));
unlink_stmt_vdef (*stmt);
gsi_remove (gsi, true);
+ sra_stats.deleted++;
return SRA_SA_REMOVED;
}
else
@@ -2274,6 +2316,18 @@ perform_intra_sra (void)
scan_function (sra_modify_expr, sra_modify_assign, NULL,
false, NULL);
initialize_parameter_reductions ();
+
+ statistics_counter_event (cfun, "Scalar replacements created",
+ sra_stats.replacements);
+ statistics_counter_event (cfun, "Modified expressions", sra_stats.exprs);
+ statistics_counter_event (cfun, "Subtree copy stmts",
+ sra_stats.subtree_copies);
+ statistics_counter_event (cfun, "Subreplacement stmts",
+ sra_stats.subreplacements);
+ statistics_counter_event (cfun, "Deleted stmts", sra_stats.deleted);
+ statistics_counter_event (cfun, "Separate LHS and RHS handling",
+ sra_stats.separate_lhs_rhs_handling);
+
ret = TODO_update_ssa;
out: