2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-03-25 10:40:56 +08:00

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
This commit is contained in:
Zdenek Dvorak 2007-08-04 03:09:12 +02:00 committed by Zdenek Dvorak
parent a83e7facc5
commit f87000d0c4
10 changed files with 81 additions and 36 deletions

@ -1,3 +1,24 @@
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>
PR middle-end/32399

@ -502,7 +502,6 @@ flow_loops_find (struct loops *loops)
sbitmap_free (headers);
loops->exits = NULL;
loops->state = 0;
return VEC_length (loop_p, loops->larray);
}
@ -996,7 +995,7 @@ rescan_loop_exit (edge e, bool new_edge, bool removed)
struct loop_exit *exits = NULL, *exit;
struct loop *aloop, *cloop;
if ((current_loops->state & LOOPS_HAVE_RECORDED_EXITS) == 0)
if (!loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
return;
if (!removed
@ -1054,9 +1053,9 @@ record_loop_exits (void)
if (!current_loops)
return;
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS)
if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
return;
current_loops->state |= LOOPS_HAVE_RECORDED_EXITS;
loops_state_set (LOOPS_HAVE_RECORDED_EXITS);
gcc_assert (current_loops->exits == NULL);
current_loops->exits = htab_create_alloc (2 * number_of_loops (),
@ -1109,10 +1108,10 @@ dump_recorded_exits (FILE *file)
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);
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. */
@ -1131,7 +1130,7 @@ get_loop_exit_edges (const struct loop *loop)
/* If we maintain the lists of exits, use them. Otherwise we must
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)
VEC_safe_push (edge, heap, edges, exit->e);
@ -1352,13 +1351,13 @@ verify_loop_structure (void)
{
i = loop->num;
if ((current_loops->state & LOOPS_HAVE_PREHEADERS)
if (loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS)
&& EDGE_COUNT (loop->header->preds) != 2)
{
error ("loop %d's header does not have exactly 2 entries", i);
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))
{
@ -1381,7 +1380,7 @@ verify_loop_structure (void)
error ("loop %d's header does not belong directly to it", i);
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))
{
error ("loop %d's latch is marked as part of irreducible region", i);
@ -1390,7 +1389,7 @@ verify_loop_structure (void)
}
/* 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. */
irreds = sbitmap_alloc (last_basic_block);
@ -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)
{
@ -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;
@ -1570,7 +1569,7 @@ loop_preheader_edge (const struct loop *loop)
edge e;
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)
if (e->src != loop->latch)
@ -1597,7 +1596,7 @@ single_exit (const struct loop *loop)
{
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;
if (exit->e && exit->next == loop->exits)

@ -451,6 +451,33 @@ number_of_loops (void)
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. */
/* Flags for loop iteration. */

@ -156,7 +156,7 @@ mark_irreducible_loops (void)
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. */

@ -385,7 +385,7 @@ remove_path (edge e)
fix_loop_placements (from->loop_father, &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 ();
return true;
@ -1190,7 +1190,7 @@ create_preheaders (int flags)
FOR_EACH_LOOP (li, loop, 0)
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. */
@ -1211,7 +1211,7 @@ force_single_succ_latches (void)
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
@ -1390,8 +1390,6 @@ fix_loop_structure (bitmap changed_bbs)
bool record_exits = false;
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
the loop hierarchy, so that we can recognize blocks whose loop nesting
relationship has changed. */
@ -1402,7 +1400,7 @@ fix_loop_structure (bitmap changed_bbs)
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 ();
record_exits = true;
@ -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);
if (current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES)
if (loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_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 ();
if (record_exits)

@ -59,7 +59,7 @@ loop_optimizer_init (unsigned flags)
passes may want. */
gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES
| LOOPS_HAVE_RECORDED_EXITS)) == 0);
current_loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES;
loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES);
}
else
disambiguate_loops_with_multiple_latches ();
@ -105,7 +105,7 @@ loop_optimizer_finalize (void)
}
/* Clean up. */
if (current_loops->state & LOOPS_HAVE_RECORDED_EXITS)
if (loops_state_satisfies_p (LOOPS_HAVE_RECORDED_EXITS))
release_recorded_exits ();
flow_loops_free (current_loops);
ggc_free (current_loops);

@ -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
of loop exit phi nodes. */
if (current_loops
&& (current_loops->state & LOOP_CLOSED_SSA)
&& loops_state_satisfies_p (LOOP_CLOSED_SSA)
&& is_gimple_reg (def)
&& TREE_CODE (use) == SSA_NAME
&& a->loop_father != b->loop_father)

@ -666,7 +666,7 @@ cleanup_tree_cfg_noloop (void)
timevar_pop (TV_TREE_CLEANUP_CFG);
if (changed && current_loops)
current_loops->state |= LOOPS_NEED_FIXUP;
loops_state_set (LOOPS_NEED_FIXUP);
return changed;
}
@ -682,7 +682,7 @@ repair_loop_structures (void)
/* 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
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);
BITMAP_FREE (changed_bbs);
@ -692,7 +692,7 @@ repair_loop_structures (void)
#endif
scev_reset ();
current_loops->state &= ~LOOPS_NEED_FIXUP;
loops_state_clear (LOOPS_NEED_FIXUP);
}
/* Cleanup cfg and repair loop structures. */
@ -703,7 +703,7 @@ cleanup_tree_cfg (void)
bool changed = cleanup_tree_cfg_noloop ();
if (current_loops != NULL
&& (current_loops->state & LOOPS_NEED_FIXUP))
&& loops_state_satisfies_p (LOOPS_NEED_FIXUP))
repair_loop_structures ();
return changed;

@ -365,7 +365,7 @@ rewrite_into_loop_closed_ssa (bitmap changed_bbs, unsigned update_flag)
unsigned i, old_num_ssa_names;
bitmap names_to_rename;
current_loops->state |= LOOP_CLOSED_SSA;
loops_state_set (LOOP_CLOSED_SSA);
if (number_of_loops () <= 1)
return;
@ -584,9 +584,9 @@ tree_duplicate_loop_to_header_edge (struct loop *loop, edge e,
{
unsigned first_new_block;
if (!(current_loops->state & LOOPS_HAVE_SIMPLE_LATCHES))
if (!loops_state_satisfies_p (LOOPS_HAVE_SIMPLE_LATCHES))
return false;
if (!(current_loops->state & LOOPS_HAVE_PREHEADERS))
if (!loops_state_satisfies_p (LOOPS_HAVE_PREHEADERS))
return false;
#ifdef ENABLE_CHECKING

@ -1077,7 +1077,7 @@ thread_through_all_blocks (bool may_peel_loop_headers)
threaded_edges = NULL;
if (retval)
current_loops->state |= LOOPS_NEED_FIXUP;
loops_state_set (LOOPS_NEED_FIXUP);
return retval;
}