Commit 0728902f by Richard Henderson Committed by Jan Hubicka

flow.c (redirect_edge_and_branch): Bail out on complex edges.

	* flow.c (redirect_edge_and_branch): Bail out on complex edges.
	(try_optimize_cfg): Do not remove tail recursive labels before sibcall.
	* jump.c (mark_jump_label): Do not forward branches.

Co-Authored-By: Jan Hubicka <jh@suse.cz>

From-SVN: r44118
parent 02d92e3b
Wed Jul 18 18:46:30 CEST 2001 Richard Henderson <rth@cygnus.com>
Jan Hubicka <jh@suse.cz>
* flow.c (redirect_edge_and_branch): Bail out on complex edges.
(try_optimize_cfg): Do not remove tail recursive labels before sibcall.
* jump.c (mark_jump_label): Do not forward branches.
Wed Jul 18 18:35:01 CEST 2001 Jan Hubicka <jh@suse.cz> Wed Jul 18 18:35:01 CEST 2001 Jan Hubicka <jh@suse.cz>
* cse.c (delete_trivially_dead_insns): Delete the libcall block * cse.c (delete_trivially_dead_insns): Delete the libcall block
......
...@@ -1777,6 +1777,9 @@ redirect_edge_and_branch (e, target) ...@@ -1777,6 +1777,9 @@ redirect_edge_and_branch (e, target)
basic_block src = e->src; basic_block src = e->src;
rtx insn = src->end; rtx insn = src->end;
if (e->flags & EDGE_COMPLEX)
return false;
if (try_redirect_by_replacing_jump (e, target)) if (try_redirect_by_replacing_jump (e, target))
return true; return true;
/* Do this fast path late, as we want above code to simplify for cases /* Do this fast path late, as we want above code to simplify for cases
...@@ -3683,30 +3686,15 @@ try_optimize_cfg (mode) ...@@ -3683,30 +3686,15 @@ try_optimize_cfg (mode)
changed = 1; changed = 1;
b = c; b = c;
} }
/* The fallthru forwarder block can be deleted. */
if (b->pred->pred_next == NULL
&& forwarder_block_p (b)
&& n_basic_blocks > 1
&& (b->pred->flags & EDGE_FALLTHRU)
&& (b->succ->flags & EDGE_FALLTHRU))
{
if (rtl_dump_file)
fprintf (rtl_dump_file, "Deleting fallthru block %i.\n",
b->index);
c = BASIC_BLOCK (i ? i - 1 : i + 1);
redirect_edge_succ (b->pred, b->succ->dest);
flow_delete_block (b);
changed = 1;
b = c;
}
/* Remove code labels no longer used. /* Remove code labels no longer used.
Don't do the optimization before sibling calls are discovered, Don't do the optimization before sibling calls are discovered,
as some branches may be hidden inside CALL_PLACEHOLDERs. */ as some branches may be hidden inside CALL_PLACEHOLDERs. */
if (!(mode & CLEANUP_PRE_SIBCALL) if (b->pred->pred_next == NULL
&& b->pred->pred_next == NULL
&& (b->pred->flags & EDGE_FALLTHRU) && (b->pred->flags & EDGE_FALLTHRU)
&& !(b->pred->flags & EDGE_COMPLEX)
&& GET_CODE (b->head) == CODE_LABEL && GET_CODE (b->head) == CODE_LABEL
&& (!(mode & CLEANUP_PRE_SIBCALL)
|| !tail_recursion_label_p (b->head))
/* If previous block does end with condjump jumping to next BB, /* If previous block does end with condjump jumping to next BB,
we can't delete the label. */ we can't delete the label. */
&& (b->pred->src == ENTRY_BLOCK_PTR && (b->pred->src == ENTRY_BLOCK_PTR
...@@ -3719,12 +3707,31 @@ try_optimize_cfg (mode) ...@@ -3719,12 +3707,31 @@ try_optimize_cfg (mode)
fprintf (rtl_dump_file, "Deleted label in block %i.\n", fprintf (rtl_dump_file, "Deleted label in block %i.\n",
b->index); b->index);
} }
/* The fallthru forwarder block can be deleted. */
if (b->pred->pred_next == NULL
&& forwarder_block_p (b)
&& n_basic_blocks > 1
&& (b->pred->flags & EDGE_FALLTHRU)
&& (b->succ->flags & EDGE_FALLTHRU)
&& GET_CODE (b->head) != CODE_LABEL)
{
if (rtl_dump_file)
fprintf (rtl_dump_file, "Deleting fallthru block %i.\n",
b->index);
c = BASIC_BLOCK (i ? i - 1 : i + 1);
redirect_edge_succ (b->pred, b->succ->dest);
flow_delete_block (b);
changed = 1;
b = c;
}
/* A loop because chains of blocks might be combineable. */ /* A loop because chains of blocks might be combineable. */
while ((s = b->succ) != NULL while ((s = b->succ) != NULL
&& s->succ_next == NULL && s->succ_next == NULL
&& (s->flags & EDGE_EH) == 0 && (s->flags & EDGE_EH) == 0
&& (c = s->dest) != EXIT_BLOCK_PTR && (c = s->dest) != EXIT_BLOCK_PTR
&& !(s->flags & EDGE_COMPLEX)
&& c->pred->pred_next == NULL && c->pred->pred_next == NULL
/* If the jump insn has side effects, /* If the jump insn has side effects,
we can't kill the edge. */ we can't kill the edge. */
......
...@@ -1999,8 +1999,6 @@ mark_jump_label (x, insn, in_mem) ...@@ -1999,8 +1999,6 @@ mark_jump_label (x, insn, in_mem)
case LABEL_REF: case LABEL_REF:
{ {
rtx label = XEXP (x, 0); rtx label = XEXP (x, 0);
rtx olabel = label;
rtx next;
/* Ignore remaining references to unreachable labels that /* Ignore remaining references to unreachable labels that
have been deleted. */ have been deleted. */
...@@ -2015,23 +2013,6 @@ mark_jump_label (x, insn, in_mem) ...@@ -2015,23 +2013,6 @@ mark_jump_label (x, insn, in_mem)
if (LABEL_REF_NONLOCAL_P (x)) if (LABEL_REF_NONLOCAL_P (x))
break; break;
/* If there are other labels following this one,
replace it with the last of the consecutive labels. */
for (next = NEXT_INSN (label); next; next = NEXT_INSN (next))
{
if (GET_CODE (next) == CODE_LABEL)
label = next;
else if (GET_CODE (next) != NOTE)
break;
else if ((NOTE_LINE_NUMBER (next) == NOTE_INSN_LOOP_BEG
|| NOTE_LINE_NUMBER (next) == NOTE_INSN_FUNCTION_END
/* ??? Optional. Disables some optimizations, but
makes gcov output more accurate with -O. */
|| (flag_test_coverage
&& NOTE_LINE_NUMBER (next) > 0)))
break;
}
XEXP (x, 0) = label; XEXP (x, 0) = label;
if (! insn || ! INSN_DELETED_P (insn)) if (! insn || ! INSN_DELETED_P (insn))
++LABEL_NUSES (label); ++LABEL_NUSES (label);
...@@ -2042,27 +2023,6 @@ mark_jump_label (x, insn, in_mem) ...@@ -2042,27 +2023,6 @@ mark_jump_label (x, insn, in_mem)
JUMP_LABEL (insn) = label; JUMP_LABEL (insn) = label;
else else
{ {
/* If we've changed the label, update notes accordingly. */
if (label != olabel)
{
rtx note;
/* We may have a REG_LABEL note to indicate that this
instruction uses the label. */
note = find_reg_note (insn, REG_LABEL, olabel);
if (note)
XEXP (note, 0) = label;
/* We may also have a REG_EQUAL note to indicate that
a register is being set to the address of the
label. */
note = find_reg_note (insn, REG_EQUAL, NULL_RTX);
if (note
&& GET_CODE (XEXP (note, 0)) == LABEL_REF
&& XEXP (XEXP (note, 0), 0) == olabel)
XEXP (XEXP (note, 0), 0) = label;
}
/* Add a REG_LABEL note for LABEL unless there already /* Add a REG_LABEL note for LABEL unless there already
is one. All uses of a label, except for labels is one. All uses of a label, except for labels
that are the targets of jumps, must have a that are the targets of jumps, must have a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment