bb-reorder (chain_reorder_blocks): Changed code to test for EDGE_FALLTHRU rather than making erroneous assumption...

Tue May  2 23:38:37 2000  Jason Eckhardt  <jle@cygnus.com>

	* bb-reorder (chain_reorder_blocks): Changed code to test for
	EDGE_FALLTHRU rather than making erroneous assumption that the
	first outgoing edge is the fall-through edge.

From-SVN: r33623
This commit is contained in:
Jason Eckhardt 2000-05-03 04:41:04 +00:00 committed by Jason Eckhardt
parent 88774c2cc6
commit 3ef4c9c63e
2 changed files with 42 additions and 14 deletions

View File

@ -1,3 +1,9 @@
Tue May 2 23:38:37 2000 Jason Eckhardt <jle@cygnus.com>
* bb-reorder (chain_reorder_blocks): Changed code to test for
EDGE_FALLTHRU rather than making erroneous assumption that the
first outgoing edge is the fall-through edge.
Tue May 2 18:20:31 2000 Donald Lindsay <dlindsay@hound.cygnus.com> Tue May 2 18:20:31 2000 Donald Lindsay <dlindsay@hound.cygnus.com>
* config/mips/mips.c (mips_build_va_list,mips_va_start,mips_va_arg): new * config/mips/mips.c (mips_build_va_list,mips_va_start,mips_va_arg): new

View File

@ -323,6 +323,7 @@ chain_reorder_blocks (e, ceb)
basic_block db = e->dest; basic_block db = e->dest;
rtx cebe_insn, dbh_insn, dbe_insn; rtx cebe_insn, dbh_insn, dbe_insn;
edge ee, last_edge; edge ee, last_edge;
edge e_fallthru, e_jump;
enum cond_types {NO_COND, PREDICT_THEN_WITH_ELSE, PREDICT_ELSE, enum cond_types {NO_COND, PREDICT_THEN_WITH_ELSE, PREDICT_ELSE,
PREDICT_THEN_NO_ELSE, PREDICT_NOT_THEN_NO_ELSE}; PREDICT_THEN_NO_ELSE, PREDICT_NOT_THEN_NO_ELSE};
@ -342,25 +343,45 @@ chain_reorder_blocks (e, ceb)
&& ceb->index + 1 == db->index && NEXT_INSN (cebe_insn)) && ceb->index + 1 == db->index && NEXT_INSN (cebe_insn))
return db; return db;
e_fallthru = e_jump = e;
/* Get the type of block and type of condition. */ /* Get the type of block and type of condition. */
cond_type = NO_COND; cond_type = NO_COND;
cond_block_type = NO_COND_BLOCK; cond_block_type = NO_COND_BLOCK;
if (GET_CODE (sb->end) == JUMP_INSN && ! simplejump_p (sb->end) if (GET_CODE (sb->end) == JUMP_INSN && ! simplejump_p (sb->end)
&& condjump_p (sb->end)) && condjump_p (sb->end))
{ {
if (e->flags & EDGE_FALLTHRU)
{
if (e == sb->succ)
e_jump = sb->succ->succ_next;
else if (e == sb->succ->succ_next)
e_jump = sb->succ;
else
abort ();
}
else
{
if (e == sb->succ)
e_fallthru = sb->succ->succ_next;
else if (e == sb->succ->succ_next)
e_fallthru = sb->succ;
else
abort ();
}
if (e->flags & EDGE_FALLTHRU) if (e->flags & EDGE_FALLTHRU)
cond_block_type = THEN_BLOCK; cond_block_type = THEN_BLOCK;
else if (get_common_dest (sb->succ->dest, sb)) else if (get_common_dest (e_fallthru->dest, sb))
cond_block_type = NO_ELSE_BLOCK; cond_block_type = NO_ELSE_BLOCK;
else else
cond_block_type = ELSE_BLOCK; cond_block_type = ELSE_BLOCK;
if (sb->succ->succ_next if (get_common_dest (e_fallthru->dest, sb))
&& get_common_dest (sb->succ->dest, sb))
{ {
if (cond_block_type == THEN_BLOCK) if (cond_block_type == THEN_BLOCK)
{ {
if (! (REORDER_BLOCK_FLAGS (sb->succ->succ_next->dest) if (! (REORDER_BLOCK_FLAGS (e->dest)
& REORDER_BLOCK_VISITED)) & REORDER_BLOCK_VISITED))
cond_type = PREDICT_THEN_NO_ELSE; cond_type = PREDICT_THEN_NO_ELSE;
else else
@ -368,7 +389,7 @@ chain_reorder_blocks (e, ceb)
} }
else if (cond_block_type == NO_ELSE_BLOCK) else if (cond_block_type == NO_ELSE_BLOCK)
{ {
if (! (REORDER_BLOCK_FLAGS (sb->succ->dest) if (! (REORDER_BLOCK_FLAGS (e->dest)
& REORDER_BLOCK_VISITED)) & REORDER_BLOCK_VISITED))
cond_type = PREDICT_NOT_THEN_NO_ELSE; cond_type = PREDICT_NOT_THEN_NO_ELSE;
else else
@ -379,16 +400,16 @@ chain_reorder_blocks (e, ceb)
{ {
if (cond_block_type == THEN_BLOCK) if (cond_block_type == THEN_BLOCK)
{ {
if (! (REORDER_BLOCK_FLAGS (sb->succ->succ_next->dest) if (! (REORDER_BLOCK_FLAGS (e->dest)
& REORDER_BLOCK_VISITED)) & REORDER_BLOCK_VISITED))
cond_type = PREDICT_THEN_WITH_ELSE; cond_type = PREDICT_THEN_WITH_ELSE;
else else
cond_type = PREDICT_ELSE; cond_type = PREDICT_ELSE;
} }
else if (cond_block_type == ELSE_BLOCK else if (cond_block_type == ELSE_BLOCK
&& sb->succ->dest != EXIT_BLOCK_PTR) && e_fallthru->dest != EXIT_BLOCK_PTR)
{ {
if (! (REORDER_BLOCK_FLAGS (sb->succ->dest) if (! (REORDER_BLOCK_FLAGS (e->dest)
& REORDER_BLOCK_VISITED)) & REORDER_BLOCK_VISITED))
cond_type = PREDICT_ELSE; cond_type = PREDICT_ELSE;
else else
@ -421,25 +442,26 @@ chain_reorder_blocks (e, ceb)
if (rtl_dump_file) if (rtl_dump_file)
fprintf (rtl_dump_file, fprintf (rtl_dump_file,
" then jump from block %d to block %d\n", " then jump from block %d to block %d\n",
sb->index, sb->succ->dest->index); sb->index, e_fallthru->dest->index);
/* Jump to reordered then block. */ /* Jump to reordered then block. */
REORDER_BLOCK_ADD_JUMP (sb) = sb->succ->dest; REORDER_BLOCK_ADD_JUMP (sb) = e_fallthru->dest;
} }
/* Reflect that then block will jump back when we have no else. */ /* Reflect that then block will jump back when we have no else. */
if (cond_block_type != THEN_BLOCK if (cond_block_type != THEN_BLOCK
&& cond_type == PREDICT_NOT_THEN_NO_ELSE) && cond_type == PREDICT_NOT_THEN_NO_ELSE)
{ {
for (ee = sb->succ->dest->succ; basic_block jbb = e_fallthru->dest;
for (ee = jbb->succ;
ee && ! (ee->flags & EDGE_FALLTHRU); ee && ! (ee->flags & EDGE_FALLTHRU);
ee = ee->succ_next) ee = ee->succ_next)
continue; continue;
if (ee && ! (GET_CODE (sb->succ->dest->end) == JUMP_INSN if (ee && ! (GET_CODE (jbb->end) == JUMP_INSN
&& ! simplejump_p (sb->succ->dest->end))) && ! simplejump_p (jbb->end)))
{ {
REORDER_BLOCK_ADD_JUMP (sb->succ->dest) = ee->dest; REORDER_BLOCK_ADD_JUMP (jbb) = ee->dest;
} }
} }