summaryrefslogtreecommitdiff
path: root/gcc/cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cfg.c')
-rw-r--r--gcc/cfg.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 40e51a52041..0b0e9503b2b 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -990,9 +990,15 @@ update_bb_profile_for_threading (basic_block bb, int edge_frequency,
FOR_EACH_EDGE (c, ei, bb->succs)
{
- c->probability = RDIV (c->probability * scale, 65536);
- if (c->probability > REG_BR_PROB_BASE)
+ /* Protect from overflow due to additional scaling. */
+ if (c->probability > prob)
c->probability = REG_BR_PROB_BASE;
+ else
+ {
+ c->probability = RDIV (c->probability * scale, 65536);
+ if (c->probability > REG_BR_PROB_BASE)
+ c->probability = REG_BR_PROB_BASE;
+ }
}
}