more robust purge_dead_edges
Jan Hubicka
jh@suse.cz
Tue Jul 24 14:45:00 GMT 2001
Hi,
to make split_all_insns working, purge_dead_edges must handle conditional jumps
(I explicitly allow in the documentation) and (conditional) returns.
Bootstreapped/regtested i686
St čec 25 00:40:19 CEST 2001 Jan Hubicka <jh@suse.cz>
* flow.c (purge_dead_edges): Handle conditional jumps and conditional returns
too.
*** flow.c.old Tue Jul 24 17:13:33 2001
--- flow.c Wed Jul 25 00:37:12 2001
*************** purge_dead_edges (bb)
*** 9783,9803 ****
return;
if (GET_CODE (insn) == JUMP_INSN)
{
for (e = bb->succ; e; e = next)
{
next = e->succ_next;
! if (e->dest == EXIT_BLOCK_PTR || e->dest->head != JUMP_LABEL (insn))
! remove_edge (e);
}
! if (bb->succ && bb->succ->succ_next)
! abort ();
! if (!bb->succ)
return;
- bb->succ->probability = REG_BR_PROB_BASE;
- bb->succ->count = bb->count;
-
if (rtl_dump_file)
fprintf (rtl_dump_file, "Purged edges from bb %i\n", bb->index);
return;
}
/* If we don't see a jump insn, we don't know exactly why the block would
--- 9802,9857 ----
return;
if (GET_CODE (insn) == JUMP_INSN)
{
+ int removed = 0;
+ rtx note;
+ edge b,f;
+ /* We do care only about conditional jumps and simplejumps. */
+ if (!any_condjump_p (insn)
+ && !simplejump_p (insn))
+ return;
for (e = bb->succ; e; e = next)
{
next = e->succ_next;
!
! /* Check purposes we can have edge. */
! if ((e->flags & EDGE_FALLTHRU)
! && any_condjump_p (insn))
! continue;
! if (e->dest != EXIT_BLOCK_PTR
! && e->dest->head == JUMP_LABEL (insn))
! continue;
! if (e->dest == EXIT_BLOCK_PTR
! && returnjump_p (insn))
! continue;
! removed = 1;
! remove_edge (e);
}
! if (!bb->succ || !removed)
return;
if (rtl_dump_file)
fprintf (rtl_dump_file, "Purged edges from bb %i\n", bb->index);
+ if (!optimize)
+ return;
+
+ /* Redistribute probabilities. */
+ if (!bb->succ->succ_next)
+ {
+ bb->succ->probability = REG_BR_PROB_BASE;
+ bb->succ->count = bb->count;
+ }
+ else
+ {
+ note = find_reg_note (insn, REG_BR_PROB, NULL);
+ /* We should have prediction on each conditional jump. */
+ if (!note)
+ abort ();
+ b = BRANCH_EDGE (bb);
+ f = FALLTHRU_EDGE (bb);
+ b->probability = INTVAL (XEXP (note, 0));
+ f->probability = REG_BR_PROB_BASE - b->probability;
+ b->count = bb->count * b->probability / REG_BR_PROB_BASE;
+ f->count = bb->count * f->probability / REG_BR_PROB_BASE;
+ }
return;
}
/* If we don't see a jump insn, we don't know exactly why the block would
More information about the Gcc-patches
mailing list