summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-04 01:09:12 +0000
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-04 01:09:12 +0000
commitf24ec26f1cabb4f55cdb4370f35b67807df8fb7a (patch)
tree798273ffece1ba2938c3938e1c16af800a086eee
parente45bbad21b8f3590c89cc7193eaac430b547328f (diff)
downloadgcc-f24ec26f1cabb4f55cdb4370f35b67807df8fb7a.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127197 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog21
-rw-r--r--gcc/cfgloop.c29
-rw-r--r--gcc/cfgloop.h27
-rw-r--r--gcc/cfgloopanal.c2
-rw-r--r--gcc/cfgloopmanip.c16
-rw-r--r--gcc/loop-init.c4
-rw-r--r--gcc/tree-cfg.c2
-rw-r--r--gcc/tree-cfgcleanup.c8
-rw-r--r--gcc/tree-ssa-loop-manip.c6
-rw-r--r--gcc/tree-ssa-threadupdate.c2
10 files changed, 81 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b2bff862809..33211ce682e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c
index 411eb8eef46..fd26d5dc05d 100644
--- a/gcc/cfgloop.c
+++ b/gcc/cfgloop.c
@@ -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)
diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h
index 903672dfcf9..791dabf3989 100644
--- a/gcc/cfgloop.h
+++ b/gcc/cfgloop.h
@@ -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. */
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index e1ef68d1926..13b674aaecb 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -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. */
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index 595d5860386..c66dfd47f8a 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -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)
diff --git a/gcc/loop-init.c b/gcc/loop-init.c
index 3bdafdaab8b..af62a31a9b8 100644
--- a/gcc/loop-init.c
+++ b/gcc/loop-init.c
@@ -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);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index f124c9a436f..0c6c56a5918 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -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)
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index bd2523bf7e6..bcae4488dc1 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -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;
diff --git a/gcc/tree-ssa-loop-manip.c b/gcc/tree-ssa-loop-manip.c
index 6faac9be3bb..2ac9d1bdb63 100644
--- a/gcc/tree-ssa-loop-manip.c
+++ b/gcc/tree-ssa-loop-manip.c
@@ -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
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index a626cdd7648..e6fa4f68f8b 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -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;
}