aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/basic-block.h1
-rw-r--r--gcc/cfgcleanup.c6
-rw-r--r--gcc/cfgrtl.c24
4 files changed, 30 insertions, 16 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 76b2710..74e3bab 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+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.
diff --git a/gcc/basic-block.h b/gcc/basic-block.h
index 2e8f578..1902818 100644
--- a/gcc/basic-block.h
+++ b/gcc/basic-block.h
@@ -640,6 +640,7 @@ extern void iterate_fix_dominators (enum cdi_direction, basic_block *, int);
extern void verify_dominators (enum cdi_direction);
extern basic_block first_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"
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index 3da1ea5..fe3a3b3 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -1785,13 +1785,13 @@ try_optimize_cfg (int mode)
/* 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;
diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
index 9bf10f5..f3e0d34 100644
--- a/gcc/cfgrtl.c
+++ b/gcc/cfgrtl.c
@@ -687,7 +687,7 @@ block_label (basic_block block)
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;
@@ -703,7 +703,7 @@ try_redirect_by_replacing_jump (edge e, basic_block target, bool in_cfglayout)
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. */
@@ -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
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));
@@ -971,15 +971,13 @@ rtl_redirect_edge_and_branch (edge e, basic_block target)
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;
@@ -2437,11 +2435,11 @@ cfg_layout_redirect_edge_and_branch (edge e, basic_block dest)
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
@@ -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
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 ();