This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
fix bugs in flow jump pass
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com, patches at x86-64 dot org
- Subject: fix bugs in flow jump pass
- From: Jan Hubicka <jh at suse dot cz>
- Date: Fri, 29 Jun 2001 15:02:51 +0200
Hi
Fixes for few problems I've found in my code while experimenting with
it futher. The forwarder_block_p didn't work for fallthru blocks,
as CODE_LABEL is not active insn. I've also changed it to return true
even for blocks falling trought to exit, so I've needed to adjust
few other places.
Also there has been some problems when updating basic block frequencies
and such.
Bootstrapped/regtested i586
Honza
Fri Jun 29 14:38:10 CEST 2001 Jan Hubicka <jh@suse.cz>
* flow.c (forwarder_block_p): Fix for fallthru blocks.
(try_redirect_by_replacing_jump): Update properly the count
and frequency information.
Index: flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.410
diff -c -3 -p -r1.410 flow.c
*** flow.c 2001/06/29 03:30:17 1.410
--- flow.c 2001/06/29 12:40:09
*************** static bool
*** 1597,1614 ****
forwarder_block_p (bb)
basic_block bb;
{
! rtx insn;
if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
|| !bb->succ || bb->succ->succ_next)
return false;
! insn = next_active_insn (bb->head);
! if (!insn)
! return false;
! if (GET_CODE (insn) == CODE_LABEL
! || (GET_CODE (insn) == JUMP_INSN && onlyjump_p (insn)))
! return true;
! return false;
}
/* Return nonzero if we can reach target from src by falling trought. */
--- 1600,1618 ----
forwarder_block_p (bb)
basic_block bb;
{
! rtx insn = bb->head;
if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
|| !bb->succ || bb->succ->succ_next)
return false;
! while (insn != bb->end)
! {
! if (active_insn_p (insn))
! return false;
! insn = NEXT_INSN (insn);
! }
! return (!active_insn_p (insn)
! || (GET_CODE (insn) == JUMP_INSN && onlyjump_p (insn)));
}
/* Return nonzero if we can reach target from src by falling trought. */
*************** try_redirect_by_replacing_jump (e, targe
*** 1699,1704 ****
--- 1705,1712 ----
e->flags = EDGE_FALLTHRU;
else
e->flags = 0;
+ e->probability = REG_BR_PROB_BASE;
+ e->count = src->count;
/* Fixup barriers. */
barrier = next_nonnote_insn (insn);
*************** redirect_edge_and_branch (e, target)
*** 1766,1772 ****
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
if (XEXP (RTVEC_ELT (vec, j), 0) == old_label)
{
! RTVEC_ELT (vec, j) = gen_rtx_LABEL_REF (VOIDmode, new_label);
--LABEL_NUSES (old_label);
++LABEL_NUSES (new_label);
}
--- 1788,1794 ----
for (j = GET_NUM_ELEM (vec) - 1; j >= 0; --j)
if (XEXP (RTVEC_ELT (vec, j), 0) == old_label)
{
! RTVEC_ELT (vec, j) = gen_rtx_LABEL_REF (Pmode, new_label);
--LABEL_NUSES (old_label);
++LABEL_NUSES (new_label);
}
*************** redirect_edge_and_branch (e, target)
*** 1815,1820 ****
--- 1837,1844 ----
if (s)
{
s->flags |= e->flags;
+ s->probability += e->probability;
+ s->count += e->count;
remove_edge (e);
}
else
*************** try_simplify_condjump (src)
*** 2888,2894 ****
redirect_edge_succ (fallthru, next_block->succ->dest);
branch->flags |= EDGE_FALLTHRU;
! fallthru->flags &= EDGE_FALLTHRU;
flow_delete_block (next_block);
return true;
--- 2923,2929 ----
redirect_edge_succ (fallthru, next_block->succ->dest);
branch->flags |= EDGE_FALLTHRU;
! fallthru->flags &= ~EDGE_FALLTHRU;
flow_delete_block (next_block);
return true;