+2004-01-22 Jan Hubicka <jh@suse.cz>
+
+ * cfgcleanup.c (first_pass): New static variable.
+ (try_forward_edges): Add work limiting check for threading.
+ (try_crossjump_bb): Add work limiting check for crossjumping.
+ (try_optimize_cfg): Maintain first pass variable.
+
2004-01-22 Bob Wilson <bob.wilson@acm.org>
* config/xtensa/xtensa.c (function_arg): Generalize logic so that it
#define FORWARDER_BLOCK_P(BB) (BB_FLAGS (BB) & BB_FORWARDER_BLOCK)
+/* Set to true when we are running first pass of try_optimize_cfg loop. */
+static bool first_pass;
static bool try_crossjump_to_edge (int, edge, edge);
static bool try_crossjump_bb (int, basic_block);
static bool outgoing_edges_match (int, basic_block, basic_block);
int counter;
bool threaded = false;
int nthreaded_edges = 0;
+ bool may_thread = first_pass | (b->flags & BB_DIRTY);
next = e->succ_next;
{
basic_block new_target = NULL;
bool new_target_threaded = false;
+ may_thread |= target->flags & BB_DIRTY;
if (FORWARDER_BLOCK_P (target)
&& target->succ->dest != EXIT_BLOCK_PTR)
/* Allow to thread only over one edge at time to simplify updating
of probabilities. */
- else if (mode & CLEANUP_THREADING)
+ else if ((mode & CLEANUP_THREADING) && may_thread)
{
edge t = thread_jump (mode, e, target);
if (t)
If there is a match, we'll do it the other way around. */
if (e == fallthru)
continue;
+ /* If nothing changed since the last attempt, there is nothing
+ we can do. */
+ if (!first_pass
+ && (!(e->src->flags & BB_DIRTY)
+ && !(fallthru->src->flags & BB_DIRTY)))
+ continue;
if (try_crossjump_to_edge (mode, e, fallthru))
{
if (e->src->index > e2->src->index)
continue;
+ /* If nothing changed since the last attempt, there is nothing
+ we can do. */
+ if (!first_pass
+ && (!(e->src->flags & BB_DIRTY)
+ && !(e2->src->flags & BB_DIRTY)))
+ continue;
+
if (try_crossjump_to_edge (mode, e, e2))
{
changed = true;
FOR_EACH_BB (bb)
update_forwarder_flag (bb);
- if (mode & CLEANUP_UPDATE_LIFE)
+ if (mode & (CLEANUP_UPDATE_LIFE | CLEANUP_CROSSJUMP | CLEANUP_THREADING))
clear_bb_flags ();
if (! (* targetm.cannot_modify_jumps_p) ())
{
+ first_pass = true;
/* Attempt to merge blocks as made possible by edge removal. If
a block has only one successor, and the successor has only
one predecessor, they may be combined. */
#endif
changed_overall |= changed;
+ first_pass = false;
}
while (changed);
}