diff options
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index ccafd9a..c54305c 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) { |