diff options
Diffstat (limited to 'gcc/cfgcleanup.c')
-rw-r--r-- | gcc/cfgcleanup.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 7b2ec0dd76c..b1c94da8489 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -1699,8 +1699,6 @@ try_crossjump_to_edge (int mode, edge e1, edge e2) "Cross jumping from bb %i to bb %i; %i common insns\n", src1->index, src2->index, nmatch); - redirect_to->count += src1->count; - redirect_to->frequency += src1->frequency; /* We may have some registers visible through the block. */ df_set_bb_dirty (redirect_to); @@ -1757,6 +1755,14 @@ try_crossjump_to_edge (int mode, edge e1, edge e2) / (redirect_to->frequency + src1->frequency)); } + /* Adjust count and frequency for the block. An earlier jump + threading pass may have left the profile in an inconsistent + state (see update_bb_profile_for_threading) so we must be + prepared for overflows. */ + redirect_to->count += src1->count; + redirect_to->frequency += src1->frequency; + if (redirect_to->frequency > BB_FREQ_MAX) + redirect_to->frequency = BB_FREQ_MAX; update_br_prob_note (redirect_to); /* Edit SRC1 to go to REDIRECT_TO at NEWPOS1. */ |