+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>
* config/rs6000/rs6000.h (STRICT_ARGUMENT_NAMING): Remove.
/* If B has a single outgoing edge, but uses a
non-trivial jump instruction without side-effects, we
can either delete the jump entirely, or replace it
- with a simple unconditional jump. Use
- redirect_edge_and_branch to do the dirty work. */
+ with a simple unconditional jump. */
if (b->succ
&& ! b->succ->succ_next
&& b->succ->dest != EXIT_BLOCK_PTR
&& 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);
changed_here = true;
apply only if all edges now point to the same block. The parameters and
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)
{
basic_block src = e->src;
if (tmp || !onlyjump_p (insn))
return false;
- if ((!optimize || flow2_completed) && tablejump_p (insn, NULL, NULL))
+ if ((!optimize || reload_completed) && tablejump_p (insn, NULL, NULL))
return false;
/* Avoid removing branch with side effects. */
/* Recognize a tablejump that we are converting to a
simple jump and remove its associated CODE_LABEL
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);
barrier = next_nonnote_insn (BB_END (src));
if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
return false;
+ if (e->dest == target)
+ return true;
+
if (try_redirect_by_replacing_jump (e, target, false))
return true;
- /* Do this fast path late, as we want above code to simplify for cases
- 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))
+ if (!redirect_branch_edge (e, target))
return false;
return true;
if (e->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
return false;
- if (e->src != ENTRY_BLOCK_PTR
- && try_redirect_by_replacing_jump (e, dest, true))
+ if (e->dest == dest)
return true;
- if (e->dest == dest)
+ if (e->src != ENTRY_BLOCK_PTR
+ && try_redirect_by_replacing_jump (e, dest, true))
return true;
if (e->src == ENTRY_BLOCK_PTR
/* We should have fallthru edge in a, or we can do dummy redirection to get
it cleaned up. */
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)
abort ();