From 5deaef19e6360dc228e4b11cac2070fabdb036f4 Mon Sep 17 00:00:00 2001 From: Zdenek Dvorak Date: Wed, 11 May 2005 00:33:30 +0200 Subject: [PATCH] tree-cfg.c (tree_duplicate_sese_region): Update profile. * tree-cfg.c (tree_duplicate_sese_region): Update profile. * tree-optimize.c (init_tree_optimization_passes) Swap pass_ch and pass_profile. * tree-ssa-loop-ch.c (copy_loop_headers): Do not update profile here. Remove rewrite_into_loop_closed_ssa call. From-SVN: r99547 --- gcc/ChangeLog | 8 ++++++++ gcc/tree-cfg.c | 15 ++++++++++++++- gcc/tree-optimize.c | 2 +- gcc/tree-ssa-loop-ch.c | 21 --------------------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 59f058bcc63..7699a48945a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-05-10 Zdenek Dvorak + + * tree-cfg.c (tree_duplicate_sese_region): Update profile. + * tree-optimize.c (init_tree_optimization_passes) Swap + pass_ch and pass_profile. + * tree-ssa-loop-ch.c (copy_loop_headers): Do not update profile + here. Remove rewrite_into_loop_closed_ssa call. + 2005-05-10 Adrian Straetling * config/s390/s390.c: (s390_const_double_ok_for_constraint_p): New diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index ccafd9a7832..c54305c898b 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -4847,6 +4847,7 @@ tree_duplicate_sese_region (edge entry, edge exit, edge exit_copy; basic_block *doms; edge redirected; + int total_freq, entry_freq; if (!can_copy_bbs_p (region, n_region)) return false; @@ -4893,12 +4894,24 @@ tree_duplicate_sese_region (edge entry, edge exit, gcc_assert (!need_ssa_update_p ()); - /* Record blocks outside the region that are duplicated by something + /* Record blocks outside the region that are dominated by something inside. */ doms = xmalloc (sizeof (basic_block) * n_basic_blocks); n_doms = get_dominated_by_region (CDI_DOMINATORS, region, n_region, doms); + total_freq = entry->dest->frequency; + entry_freq = EDGE_FREQUENCY (entry); + /* Fix up corner cases, to avoid division by zero or creation of negative + frequencies. */ + if (total_freq == 0) + total_freq = 1; + else if (entry_freq > total_freq) + entry_freq = total_freq; + copy_bbs (region, n_region, region_copy, &exit, 1, &exit_copy, loop); + scale_bbs_frequencies_int (region, n_region, total_freq - entry_freq, + total_freq); + scale_bbs_frequencies_int (region_copy, n_region, entry_freq, total_freq); if (copying_header) { diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index e77c29c573a..6b1d35554f4 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -374,8 +374,8 @@ init_tree_optimization_passes (void) NEXT_PASS (pass_phiopt); NEXT_PASS (pass_may_alias); NEXT_PASS (pass_tail_recursion); - NEXT_PASS (pass_ch); NEXT_PASS (pass_profile); + NEXT_PASS (pass_ch); NEXT_PASS (pass_stdarg); NEXT_PASS (pass_sra); /* FIXME: SRA may generate arbitrary gimple code, exposing new diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index 18afec1e079..378755c9eaa 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -131,12 +131,10 @@ copy_loop_headers (void) basic_block *bbs, *copied_bbs; unsigned n_bbs; unsigned bbs_size; - gcov_type entry_count, body_count, total_count; loops = loop_optimizer_init (dump_file); if (!loops) return; - rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); /* We do not try to keep the information about irreducible regions up-to-date. */ @@ -202,8 +200,6 @@ copy_loop_headers (void) exit = single_succ_edge (loop_split_edge_with (exit, NULL)); entry = loop_preheader_edge (loop); - entry_count = entry->src->count; - body_count = exit->dest->count; if (!tree_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs)) { @@ -211,23 +207,6 @@ copy_loop_headers (void) continue; } - /* Fix profiling info. Scaling is done in gcov_type arithmetic to - avoid losing information; this is slow, but is done at most - once per loop. We special case 0 to avoid division by 0; - probably other special cases exist. */ - total_count = body_count + entry_count; - if (total_count == 0LL) - { - scale_bbs_frequencies_int (bbs, n_bbs, 0, 1); - scale_bbs_frequencies_int (copied_bbs, n_bbs, 0, 1); - } - else - { - scale_bbs_frequencies_gcov_type (bbs, n_bbs, body_count, total_count); - scale_bbs_frequencies_gcov_type (copied_bbs, n_bbs, entry_count, - total_count); - } - /* Ensure that the latch and the preheader is simple (we know that they are not now, since there was the loop exit condition. */ loop_split_edge_with (loop_preheader_edge (loop), NULL);