Commit f87000d0 by Zdenek Dvorak Committed by Zdenek Dvorak

tree-ssa-threadupdate.c (thread_through_all_blocks): Use loops' state accessor functions.

	* tree-ssa-threadupdate.c (thread_through_all_blocks): Use loops' state
	accessor functions.
	* cfgloopmanip.c (remove_path, create_preheaders,
	force_single_succ_latches, fix_loop_structure): Ditto.
	* tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa,
	tree_duplicate_loop_to_header_edge): Ditto.
	* cfgloopanal.c (mark_irreducible_loops): Ditto.
	* loop-init.c (loop_optimizer_init, loop_optimizer_finalize):
	Ditto.
	* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures,
	cleanup_tree_cfg): Ditto.
	* tree-cfg.c (tree_merge_blocks): Ditto.
	* cfgloop.c (rescan_loop_exit, record_loop_exits,
	release_recorded_exits, get_loop_exit_edges, verify_loop_structure,
	loop_preheader_edge, single_exit): Ditto.
	(flow_loops_find): Do not clear loops->state.
	* cfgloop.h (loops_state_satisfies_p, loops_state_set,
	loops_state_clear): New functions.

From-SVN: r127197
parent a83e7fac
2007-08-03 Zdenek Dvorak <ook@ucw.cz>
* tree-ssa-threadupdate.c (thread_through_all_blocks): Use loops' state
accessor functions.
* cfgloopmanip.c (remove_path, create_preheaders,
force_single_succ_latches, fix_loop_structure): Ditto.
* tree-ssa-loop-manip.c (rewrite_into_loop_closed_ssa,
tree_duplicate_loop_to_header_edge): Ditto.
* cfgloopanal.c (mark_irreducible_loops): Ditto.
* loop-init.c (loop_optimizer_init, loop_optimizer_finalize):
Ditto.
* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures,
cleanup_tree_cfg): Ditto.
* tree-cfg.c (tree_merge_blocks): Ditto.
* cfgloop.c (rescan_loop_exit, record_loop_exits,
release_recorded_exits, get_loop_exit_edges, verify_loop_structure,
loop_preheader_edge, single_exit): Ditto.
(flow_loops_find): Do not clear loops->state.
* cfgloop.h (loops_state_satisfies_p, loops_state_set,
loops_state_clear): New functions.
2007-08-03 Andrew Pinski <andrew_pinski@playstation.sony.com> 2007-08-03 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/32399 PR middle-end/32399
......
...@@ -502,7 +502,6 @@ flow_loops_find (struct loops *loops) ...@@ -502,7 +502,6 @@ flow_loops_find (struct loops *loops)
sbitmap_free (headers); sbitmap_free (headers);
loops->exits = NULL; loops->exits = NULL;
loops->state = 0;
return VEC_length (loop_p, loops->larray); return VEC_length (loop_p, loops->larray);
} }
...@@ -996,7 +995,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed) ...@@ -996,7 +995,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed)
struct loop_exit *exits = NULL, *exit; struct loop_exit *exits = NULL, *exit;
struct loop *aloop, *cloop; struct loop *aloop, *cloop;
if ((current_loops->state & LOOPS_HAVE_RECORDED_EXITS) == 0) if (!loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
return; return;
if (!removed if (!removed
...@@ -1054,9 +1053,9 @@ record_loop_exits (void) ...@@ -1054,9 +1053,9 @@ record_loop_exits (void)
if (!current_loops) if (!current_loops)
return; return;
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS) if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
return; return;
current_loops->state |= LOOPS_HAVE_RECORDED_EXITS; loops_state_set (LOOPS_HAVE_RECORDED_EXITS);
gcc_assert (current_loops->exits == NULL); gcc_assert (current_loops->exits == NULL);
current_loops->exits = htab_create_alloc (2 * number_of_loops (), current_loops->exits = htab_create_alloc (2 * number_of_loops (),
...@@ -1109,10 +1108,10 @@ dump_recorded_exits (FILE *file) ...@@ -1109,10 +1108,10 @@ dump_recorded_exits (FILE *file)
void void
release_recorded_exits (void) release_recorded_exits (void)
{ {
gcc_assert (current_loops->state & LOOPS_HAVE_RECORDED_EXITS); gcc_assert (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS));
htab_delete (current_loops->exits); htab_delete (current_loops->exits);
current_loops->exits = NULL; current_loops->exits = NULL;
current_loops->state &= ~LOOPS_HAVE_RECORDED_EXITS; loops_state_clear (LOOPS_HAVE_RECORDED_EXITS);
} }
/* Returns the list of the exit edges of a LOOP. */ /* Returns the list of the exit edges of a LOOP. */
...@@ -1131,7 +1130,7 @@ get_loop_exit_edges (const struct loop *loop) ...@@ -1131,7 +1130,7 @@ get_loop_exit_edges (const struct loop *loop)
/* If we maintain the lists of exits, use them. Otherwise we must /* If we maintain the lists of exits, use them. Otherwise we must
scan the body of the loop. */ scan the body of the loop. */
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS) if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
{ {
for (exit = loop->exits->next; exit->e; exit = exit->next) for (exit = loop->exits->next; exit->e; exit = exit->next)
VEC_safe_push (edge, heap, edges, exit->e); VEC_safe_push (edge, heap, edges, exit->e);
...@@ -1352,13 +1351,13 @@ verify_loop_structure (void) ...@@ -1352,13 +1351,13 @@ verify_loop_structure (void)
{ {
i = loop->num; i = loop->num;
if ((current_loops->state & LOOPS_HAVE_PREHEADERS) if (loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS)
&& EDGE_COUNT (loop->header->preds) != 2) && EDGE_COUNT (loop->header->preds) != 2)
{ {
error ("loop %d's header does not have exactly 2 entries", i); error ("loop %d's header does not have exactly 2 entries", i);
err = 1; err = 1;
} }
if (current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES) if (loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
{ {
if (!single_succ_p (loop->latch)) if (!single_succ_p (loop->latch))
{ {
...@@ -1381,7 +1380,7 @@ verify_loop_structure (void) ...@@ -1381,7 +1380,7 @@ verify_loop_structure (void)
error ("loop %d's header does not belong directly to it", i); error ("loop %d's header does not belong directly to it", i);
err = 1; err = 1;
} }
if ((current_loops->state & LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
&& (loop_latch_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP)) && (loop_latch_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP))
{ {
error ("loop %d's latch is marked as part of irreducible region", i); error ("loop %d's latch is marked as part of irreducible region", i);
...@@ -1390,7 +1389,7 @@ verify_loop_structure (void) ...@@ -1390,7 +1389,7 @@ verify_loop_structure (void)
} }
/* Check irreducible loops. */ /* Check irreducible loops. */
if (current_loops->state & LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
{ {
/* Record old info. */ /* Record old info. */
irreds = sbitmap_alloc (last_basic_block); irreds = sbitmap_alloc (last_basic_block);
...@@ -1476,7 +1475,7 @@ verify_loop_structure (void) ...@@ -1476,7 +1475,7 @@ verify_loop_structure (void)
} }
} }
if ((current_loops->state & LOOPS_HAVE_RECORDED_EXITS) == 0) if (!loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
{ {
if (loop->exits->next != loop->exits) if (loop->exits->next != loop->exits)
{ {
...@@ -1487,7 +1486,7 @@ verify_loop_structure (void) ...@@ -1487,7 +1486,7 @@ verify_loop_structure (void)
} }
} }
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS) if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
{ {
unsigned n_exits = 0, eloops; unsigned n_exits = 0, eloops;
...@@ -1570,7 +1569,7 @@ loop_preheader_edge (const struct loop *loop) ...@@ -1570,7 +1569,7 @@ loop_preheader_edge (const struct loop *loop)
edge e; edge e;
edge_iterator ei; edge_iterator ei;
gcc_assert ((current_loops->state & LOOPS_HAVE_PREHEADERS) != 0); gcc_assert (loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS));
FOR_EACH_EDGE (e, ei, loop->header->preds) FOR_EACH_EDGE (e, ei, loop->header->preds)
if (e->src != loop->latch) if (e->src != loop->latch)
...@@ -1597,7 +1596,7 @@ single_exit (const struct loop *loop) ...@@ -1597,7 +1596,7 @@ single_exit (const struct loop *loop)
{ {
struct loop_exit *exit = loop->exits->next; struct loop_exit *exit = loop->exits->next;
if ((current_loops->state & LOOPS_HAVE_RECORDED_EXITS) == 0) if (!loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
return NULL; return NULL;
if (exit->e && exit->next == loop->exits) if (exit->e && exit->next == loop->exits)
......
...@@ -451,6 +451,33 @@ number_of_loops (void) ...@@ -451,6 +451,33 @@ number_of_loops (void)
return VEC_length (loop_p, current_loops->larray); return VEC_length (loop_p, current_loops->larray);
} }
/* Returns true if state of the loops satisfies all properties
described by FLAGS. */
static inline bool
loops_state_satisfies_p (unsigned flags)
{
return (current_loops->state & flags) == flags;
}
/* Sets FLAGS to the loops state. */
static inline void
loops_state_set (unsigned flags)
{
current_loops->state |= flags;
}
/* Clears FLAGS from the loops state. */
static inline void
loops_state_clear (unsigned flags)
{
if (!current_loops)
return;
current_loops->state &= ~flags;
}
/* Loop iterators. */ /* Loop iterators. */
/* Flags for loop iteration. */ /* Flags for loop iteration. */
......
...@@ -156,7 +156,7 @@ mark_irreducible_loops (void) ...@@ -156,7 +156,7 @@ mark_irreducible_loops (void)
free_graph (g); free_graph (g);
current_loops->state |= LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS; loops_state_set (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS);
} }
/* Counts number of insns inside LOOP. */ /* Counts number of insns inside LOOP. */
......
...@@ -385,7 +385,7 @@ remove_path (edge e) ...@@ -385,7 +385,7 @@ remove_path (edge e)
fix_loop_placements (from->loop_father, &irred_invalidated); fix_loop_placements (from->loop_father, &irred_invalidated);
if (irred_invalidated if (irred_invalidated
&& (current_loops->state & LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) != 0) && loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
mark_irreducible_loops (); mark_irreducible_loops ();
return true; return true;
...@@ -1190,7 +1190,7 @@ create_preheaders (int flags) ...@@ -1190,7 +1190,7 @@ create_preheaders (int flags)
FOR_EACH_LOOP (li, loop, 0) FOR_EACH_LOOP (li, loop, 0)
create_preheader (loop, flags); create_preheader (loop, flags);
current_loops->state |= LOOPS_HAVE_PREHEADERS; loops_state_set (LOOPS_HAVE_PREHEADERS);
} }
/* Forces all loop latches to have only single successor. */ /* Forces all loop latches to have only single successor. */
...@@ -1211,7 +1211,7 @@ force_single_succ_latches (void) ...@@ -1211,7 +1211,7 @@ force_single_succ_latches (void)
split_edge (e); split_edge (e);
} }
current_loops->state |= LOOPS_HAVE_SIMPLE_LATCHES; loops_state_set (LOOPS_HAVE_SIMPLE_LATCHES);
} }
/* This function is called from loop_version. It splits the entry edge /* This function is called from loop_version. It splits the entry edge
...@@ -1390,8 +1390,6 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1390,8 +1390,6 @@ fix_loop_structure (bitmap changed_bbs)
bool record_exits = false; bool record_exits = false;
struct loop **superloop = XNEWVEC (struct loop *, number_of_loops ()); struct loop **superloop = XNEWVEC (struct loop *, number_of_loops ());
gcc_assert (current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES);
/* Remove the old bb -> loop mapping. Remember the depth of the blocks in /* Remove the old bb -> loop mapping. Remember the depth of the blocks in
the loop hierarchy, so that we can recognize blocks whose loop nesting the loop hierarchy, so that we can recognize blocks whose loop nesting
relationship has changed. */ relationship has changed. */
...@@ -1402,7 +1400,7 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1402,7 +1400,7 @@ fix_loop_structure (bitmap changed_bbs)
bb->loop_father = current_loops->tree_root; bb->loop_father = current_loops->tree_root;
} }
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS) if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
{ {
release_recorded_exits (); release_recorded_exits ();
record_exits = true; record_exits = true;
...@@ -1464,13 +1462,13 @@ fix_loop_structure (bitmap changed_bbs) ...@@ -1464,13 +1462,13 @@ fix_loop_structure (bitmap changed_bbs)
} }
} }
if (current_loops->state & LOOPS_HAVE_PREHEADERS) if (loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
create_preheaders (CP_SIMPLE_PREHEADERS); create_preheaders (CP_SIMPLE_PREHEADERS);
if (current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES) if (loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
force_single_succ_latches (); force_single_succ_latches ();
if (current_loops->state & LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) if (loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))
mark_irreducible_loops (); mark_irreducible_loops ();
if (record_exits) if (record_exits)
......
...@@ -59,7 +59,7 @@ loop_optimizer_init (unsigned flags) ...@@ -59,7 +59,7 @@ loop_optimizer_init (unsigned flags)
passes may want. */ passes may want. */
gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES
| LOOPS_HAVE_RECORDED_EXITS)) == 0); | LOOPS_HAVE_RECORDED_EXITS)) == 0);
current_loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES; loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
} }
else else
disambiguate_loops_with_multiple_latches (); disambiguate_loops_with_multiple_latches ();
...@@ -105,7 +105,7 @@ loop_optimizer_finalize (void) ...@@ -105,7 +105,7 @@ loop_optimizer_finalize (void)
} }
/* Clean up. */ /* Clean up. */
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS) if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
release_recorded_exits (); release_recorded_exits ();
flow_loops_free (current_loops); flow_loops_free (current_loops);
ggc_free (current_loops); ggc_free (current_loops);
......
...@@ -1292,7 +1292,7 @@ tree_merge_blocks (basic_block a, basic_block b) ...@@ -1292,7 +1292,7 @@ tree_merge_blocks (basic_block a, basic_block b)
/* In case we maintain loop closed ssa form, do not propagate arguments /* In case we maintain loop closed ssa form, do not propagate arguments
of loop exit phi nodes. */ of loop exit phi nodes. */
if (current_loops if (current_loops
&& (current_loops->state & LOOP_CLOSED_SSA) && loops_state_satisfies_p (LOOP_CLOSED_SSA)
&& is_gimple_reg (def) && is_gimple_reg (def)
&& TREE_CODE (use) == SSA_NAME && TREE_CODE (use) == SSA_NAME
&& a->loop_father != b->loop_father) && a->loop_father != b->loop_father)
......
...@@ -666,7 +666,7 @@ cleanup_tree_cfg_noloop (void) ...@@ -666,7 +666,7 @@ cleanup_tree_cfg_noloop (void)
timevar_pop (TV_TREE_CLEANUP_CFG); timevar_pop (TV_TREE_CLEANUP_CFG);
if (changed && current_loops) if (changed && current_loops)
current_loops->state |= LOOPS_NEED_FIXUP; loops_state_set (LOOPS_NEED_FIXUP);
return changed; return changed;
} }
...@@ -682,7 +682,7 @@ repair_loop_structures (void) ...@@ -682,7 +682,7 @@ repair_loop_structures (void)
/* This usually does nothing. But sometimes parts of cfg that originally /* This usually does nothing. But sometimes parts of cfg that originally
were inside a loop get out of it due to edge removal (since they were inside a loop get out of it due to edge removal (since they
become unreachable by back edges from latch). */ become unreachable by back edges from latch). */
if ((current_loops->state & LOOP_CLOSED_SSA) != 0) if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa); rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
BITMAP_FREE (changed_bbs); BITMAP_FREE (changed_bbs);
...@@ -692,7 +692,7 @@ repair_loop_structures (void) ...@@ -692,7 +692,7 @@ repair_loop_structures (void)
#endif #endif
scev_reset (); scev_reset ();
current_loops->state &= ~LOOPS_NEED_FIXUP; loops_state_clear (LOOPS_NEED_FIXUP);
} }
/* Cleanup cfg and repair loop structures. */ /* Cleanup cfg and repair loop structures. */
...@@ -703,7 +703,7 @@ cleanup_tree_cfg (void) ...@@ -703,7 +703,7 @@ cleanup_tree_cfg (void)
bool changed = cleanup_tree_cfg_noloop (); bool changed = cleanup_tree_cfg_noloop ();
if (current_loops != NULL if (current_loops != NULL
&& (current_loops->state & LOOPS_NEED_FIXUP)) && loops_state_satisfies_p (LOOPS_NEED_FIXUP))
repair_loop_structures (); repair_loop_structures ();
return changed; return changed;
......
...@@ -365,7 +365,7 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag) ...@@ -365,7 +365,7 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag)
unsigned i, old_num_ssa_names; unsigned i, old_num_ssa_names;
bitmap names_to_rename; bitmap names_to_rename;
current_loops->state |= LOOP_CLOSED_SSA; loops_state_set (LOOP_CLOSED_SSA);
if (number_of_loops () <= 1) if (number_of_loops () <= 1)
return; return;
...@@ -584,9 +584,9 @@ tree_duplicate_loop_to_header_edge (struct loop *loop, edge e, ...@@ -584,9 +584,9 @@ tree_duplicate_loop_to_header_edge (struct loop *loop, edge e,
{ {
unsigned first_new_block; unsigned first_new_block;
if (!(current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES)) if (!loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
return false; return false;
if (!(current_loops->state & LOOPS_HAVE_PREHEADERS)) if (!loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
return false; return false;
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
......
...@@ -1077,7 +1077,7 @@ thread_through_all_blocks (bool may_peel_loop_headers) ...@@ -1077,7 +1077,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
threaded_edges = NULL; threaded_edges = NULL;
if (retval) if (retval)
current_loops->state |= LOOPS_NEED_FIXUP; loops_state_set (LOOPS_NEED_FIXUP);
return retval; return retval;
} }
......
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