diff options
author | Martin Jambor <mjambor@suse.cz> | 2009-06-18 17:38:36 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2009-06-18 17:38:36 +0200 |
commit | 2a45675fd08dd485d1766008982995d23c6a3e85 (patch) | |
tree | 439adfe3d9e1f960cc6f4f06d9d64cc8daa17594 /gcc/tree-sra.c | |
parent | b506a5a2387f4a5f69a8c23840e1c733bcb1e595 (diff) | |
download | gcc-2a45675fd08dd485d1766008982995d23c6a3e85.zip gcc-2a45675fd08dd485d1766008982995d23c6a3e85.tar.gz gcc-2a45675fd08dd485d1766008982995d23c6a3e85.tar.bz2 |
tree-sra.c: Include statistics.h
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.
From-SVN: r148663
Diffstat (limited to 'gcc/tree-sra.c')
-rw-r--r-- | gcc/tree-sra.c | 68 |
1 files changed, 61 insertions, 7 deletions
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: |