FOR_BB_BETWEEN (bb, min, max->next_bb, next_bb)
{
edge e;
+ edge_iterator ei;
- for (e = bb->succ; e ; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest != EXIT_BLOCK_PTR)
SET_BIT (edge_cache[bb->index], e->dest->index);
}
enum rtx_code code;
int force_fallthru = 0;
edge e;
+ edge_iterator ei;
if (LABEL_P (BB_HEAD (bb))
&& LABEL_ALT_ENTRY_P (BB_HEAD (bb)))
/* Find out if we can drop through to the next block. */
insn = NEXT_INSN (insn);
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
{
insn = 0;
compute_outgoing_frequencies (basic_block b)
{
edge e, f;
+ edge_iterator ei;
- if (b->succ && b->succ->succ_next && !b->succ->succ_next->succ_next)
+ if (EDGE_COUNT (b->succs) == 2)
{
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)
+ if (EDGE_COUNT (b->succs) == 1)
{
- e = b->succ;
+ e = EDGE_SUCC (b, 0);
e->probability = REG_BR_PROB_BASE;
e->count = b->count;
+ return;
}
+ guess_outgoing_edge_probabilities (b);
+ if (b->count)
+ FOR_EACH_EDGE (e, ei, b->succs)
+ 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
/* 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;
+ edge_iterator ei;
+
+ if (STATE (bb) == BLOCK_ORIGINAL)
+ continue;
+ if (STATE (bb) == BLOCK_NEW)
+ {
+ bb->count = 0;
+ bb->frequency = 0;
+ FOR_EACH_EDGE (e, ei, bb->preds)
+ {
+ 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);
FOR_BB_BETWEEN (b, min, max->next_bb, next_bb)
{
edge e;
+ edge_iterator ei;
if (b != min)
{
b->count = 0;
b->frequency = 0;
- for (e = b->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, b->preds)
{
b->count += e->count;
b->frequency += EDGE_FREQUENCY (e);