Commit 3348b696 by Jan Hubicka Committed by Jan Hubicka

basic-block.h (try_redirect_by_replacing_jump): Declare.

	* basic-block.h (try_redirect_by_replacing_jump): Declare.
	* cfgcleanup.c (try_optimize_cfg): Use it.
	* cfgrtl.c (try_redirect_by_replacing_jump): Export.
	(rtl_redirect_edge_and_branch, cfg_layout_redirect_edge_and_branch):
	Kill hack.
	(cfg_layout_merge_blocks): Use try_redirect_by_replacing_jump.

	Revert:
	2004-01-16  Geoffrey Keating  <geoffk@apple.com>

		* cfgrtl.c (try_redirect_by_replacing_jump): Optimize tablejumps
		even after reload, just don't remove the actual jump tables.

From-SVN: r76115
parent 72d89d35
2004-01-18 Jan Hubicka <jh@suse.cz>
* basic-block.h (try_redirect_by_replacing_jump): Declare.
* cfgcleanup.c (try_optimize_cfg): Use it.
* cfgrtl.c (try_redirect_by_replacing_jump): Export.
(rtl_redirect_edge_and_branch, cfg_layout_redirect_edge_and_branch):
Kill hack.
(cfg_layout_merge_blocks): Use try_redirect_by_replacing_jump.
Revert:
2004-01-16 Geoffrey Keating <geoffk@apple.com>
* cfgrtl.c (try_redirect_by_replacing_jump): Optimize tablejumps
even after reload, just don't remove the actual jump tables.
2004-01-18 Kazu Hirata <kazu@cs.umass.edu> 2004-01-18 Kazu Hirata <kazu@cs.umass.edu>
* config/rs6000/rs6000.h (STRICT_ARGUMENT_NAMING): Remove. * config/rs6000/rs6000.h (STRICT_ARGUMENT_NAMING): Remove.
......
...@@ -640,6 +640,7 @@ extern void iterate_fix_dominators (enum cdi_direction, basic_block *, int); ...@@ -640,6 +640,7 @@ extern void iterate_fix_dominators (enum cdi_direction, basic_block *, int);
extern void verify_dominators (enum cdi_direction); extern void verify_dominators (enum cdi_direction);
extern basic_block first_dom_son (enum cdi_direction, basic_block); extern basic_block first_dom_son (enum cdi_direction, basic_block);
extern basic_block next_dom_son (enum cdi_direction, basic_block); extern basic_block next_dom_son (enum cdi_direction, basic_block);
extern bool try_redirect_by_replacing_jump (edge, basic_block, bool);
#include "cfghooks.h" #include "cfghooks.h"
......
...@@ -1785,13 +1785,13 @@ try_optimize_cfg (int mode) ...@@ -1785,13 +1785,13 @@ try_optimize_cfg (int mode)
/* If B has a single outgoing edge, but uses a /* If B has a single outgoing edge, but uses a
non-trivial jump instruction without side-effects, we non-trivial jump instruction without side-effects, we
can either delete the jump entirely, or replace it can either delete the jump entirely, or replace it
with a simple unconditional jump. Use with a simple unconditional jump. */
redirect_edge_and_branch to do the dirty work. */
if (b->succ if (b->succ
&& ! b->succ->succ_next && ! b->succ->succ_next
&& b->succ->dest != EXIT_BLOCK_PTR && b->succ->dest != EXIT_BLOCK_PTR
&& onlyjump_p (BB_END (b)) && onlyjump_p (BB_END (b))
&& redirect_edge_and_branch (b->succ, b->succ->dest)) && try_redirect_by_replacing_jump (b->succ, b->succ->dest,
(mode & CLEANUP_CFGLAYOUT)))
{ {
update_forwarder_flag (b); update_forwarder_flag (b);
changed_here = true; changed_here = true;
......
...@@ -687,7 +687,7 @@ block_label (basic_block block) ...@@ -687,7 +687,7 @@ block_label (basic_block block)
apply only if all edges now point to the same block. The parameters and apply only if all edges now point to the same block. The parameters and
return values are equivalent to redirect_edge_and_branch. */ return values are equivalent to redirect_edge_and_branch. */
static bool bool
try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
{ {
basic_block src = e->src; basic_block src = e->src;
...@@ -703,7 +703,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) ...@@ -703,7 +703,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
if (tmp || !onlyjump_p (insn)) if (tmp || !onlyjump_p (insn))
return false; return false;
if ((!optimize || flow2_completed) && tablejump_p (insn, NULL, NULL)) if ((!optimize || reload_completed) && tablejump_p (insn, NULL, NULL))
return false; return false;
/* Avoid removing branch with side effects. */ /* Avoid removing branch with side effects. */
...@@ -793,7 +793,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout) ...@@ -793,7 +793,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
/* Recognize a tablejump that we are converting to a /* Recognize a tablejump that we are converting to a
simple jump and remove its associated CODE_LABEL simple jump and remove its associated CODE_LABEL
and ADDR_VEC or ADDR_DIFF_VEC. */ and ADDR_VEC or ADDR_DIFF_VEC. */
if (! reload_completed && tablejump_p (insn, &label, &table)) if (tablejump_p (insn, &label, &table))
delete_insn_chain (label, table); delete_insn_chain (label, table);
barrier = next_nonnote_insn (BB_END (src)); barrier = next_nonnote_insn (BB_END (src));
...@@ -971,15 +971,13 @@ rtl_redirect_edge_and_branch (edge e, basic_block target) ...@@ -971,15 +971,13 @@ rtl_redirect_edge_and_branch (edge e, basic_block target)
if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)) if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
return false; return false;
if (e->dest == target)
return true;
if (try_redirect_by_replacing_jump (e, target, false)) if (try_redirect_by_replacing_jump (e, target, false))
return true; return true;
/* Do this fast path late, as we want above code to simplify for cases if (!redirect_branch_edge (e, target))
where called on single edge leaving basic block containing nontrivial
jump insn. */
else if (e->dest == target)
return false;
else if (!redirect_branch_edge (e, target))
return false; return false;
return true; return true;
...@@ -2437,11 +2435,11 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest) ...@@ -2437,11 +2435,11 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH)) if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
return false; return false;
if (e->src != ENTRY_BLOCK_PTR if (e->dest == dest)
&& try_redirect_by_replacing_jump (e, dest, true))
return true; return true;
if (e->dest == dest) if (e->src != ENTRY_BLOCK_PTR
&& try_redirect_by_replacing_jump (e, dest, true))
return true; return true;
if (e->src == ENTRY_BLOCK_PTR if (e->src == ENTRY_BLOCK_PTR
...@@ -2627,7 +2625,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b) ...@@ -2627,7 +2625,7 @@ cfg_layout_merge_blocks (basic_block a, basic_block b)
/* We should have fallthru edge in a, or we can do dummy redirection to get /* We should have fallthru edge in a, or we can do dummy redirection to get
it cleaned up. */ it cleaned up. */
if (GET_CODE (BB_END (a)) == JUMP_INSN) if (GET_CODE (BB_END (a)) == JUMP_INSN)
redirect_edge_and_branch (a->succ, b); try_redirect_by_replacing_jump (a->succ, b, true);
if (GET_CODE (BB_END (a)) == JUMP_INSN) if (GET_CODE (BB_END (a)) == JUMP_INSN)
abort (); abort ();
......
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