summaryrefslogtreecommitdiff
path: root/gcc/cfgbuild.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 12:20:40 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-09 12:20:40 +0000
commit83c8a97789c308913dac832723c3596d408cb6eb (patch)
treed0a7e707ffda1026a1023f45c18e9c7f465037ff /gcc/cfgbuild.c
parent5e8f3c31e20da10db3a8b658815c7a3acc5ca97d (diff)
downloadgcc-83c8a97789c308913dac832723c3596d408cb6eb.tar.gz
* basic-block.h (guess_outgoing_edge_probabilities): Declare.
* cfgbuild.c (compute_outgoing_frequencies): When probability is missing, guess it. (find_many_sub_basic_blocks): Do update profile only when it is present. * predict.c (set_even_probabilities): Break out from ... (combine_predictions_for_insn): ... here; deal with !can_predict_insn_p insns. (combine_predictions_for_bb): Use set_even_probabilities. (bb_estimate_probability_locally): Break out from .... (estimate_probability): ... here. (guess_outgoing_edge_probabilities): New entry point. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87234 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgbuild.c')
-rw-r--r--gcc/cfgbuild.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 2f59d7e982c..453e65cf495 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -646,17 +646,18 @@ compute_outgoing_frequencies (basic_block b)
rtx note = find_reg_note (BB_END (b), REG_BR_PROB, NULL);
int probability;
- if (!note)
- return;
-
- probability = INTVAL (XEXP (note, 0));
- e = BRANCH_EDGE (b);
- e->probability = probability;
- e->count = ((b->count * probability + REG_BR_PROB_BASE / 2)
- / REG_BR_PROB_BASE);
- f = FALLTHRU_EDGE (b);
- f->probability = REG_BR_PROB_BASE - probability;
- f->count = b->count - e->count;
+ if (note)
+ {
+ probability = INTVAL (XEXP (note, 0));
+ e = BRANCH_EDGE (b);
+ e->probability = probability;
+ e->count = ((b->count * probability + REG_BR_PROB_BASE / 2)
+ / REG_BR_PROB_BASE);
+ f = FALLTHRU_EDGE (b);
+ f->probability = REG_BR_PROB_BASE - probability;
+ f->count = b->count - e->count;
+ return;
+ }
}
if (b->succ && !b->succ->succ_next)
@@ -664,7 +665,13 @@ compute_outgoing_frequencies (basic_block b)
e = b->succ;
e->probability = REG_BR_PROB_BASE;
e->count = b->count;
+ return;
}
+ guess_outgoing_edge_probabilities (b);
+ if (b->count)
+ for (e = b->succ; e; e = e->succ_next)
+ e->count = ((b->count * e->probability + REG_BR_PROB_BASE / 2)
+ / REG_BR_PROB_BASE);
}
/* Assume that someone emitted code with control flow instructions to the
@@ -698,25 +705,26 @@ find_many_sub_basic_blocks (sbitmap blocks)
/* Update branch probabilities. Expect only (un)conditional jumps
to be created with only the forward edges. */
- FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
- {
- edge e;
-
- if (STATE (bb) == BLOCK_ORIGINAL)
- continue;
- if (STATE (bb) == BLOCK_NEW)
- {
- bb->count = 0;
- bb->frequency = 0;
- for (e = bb->pred; e; e = e->pred_next)
- {
- bb->count += e->count;
- bb->frequency += EDGE_FREQUENCY (e);
- }
- }
+ if (profile_status != PROFILE_ABSENT)
+ FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
+ {
+ edge e;
+
+ if (STATE (bb) == BLOCK_ORIGINAL)
+ continue;
+ if (STATE (bb) == BLOCK_NEW)
+ {
+ bb->count = 0;
+ bb->frequency = 0;
+ for (e = bb->pred; e; e = e->pred_next)
+ {
+ bb->count += e->count;
+ bb->frequency += EDGE_FREQUENCY (e);
+ }
+ }
- compute_outgoing_frequencies (bb);
- }
+ compute_outgoing_frequencies (bb);
+ }
FOR_EACH_BB (bb)
SET_STATE (bb, 0);