]> gcc.gnu.org Git - gcc.git/commitdiff
tree-ssa-threadupdate.c (thread_through_all_blocks): Use loops' state accessor functions.
authorZdenek Dvorak <ook@ucw.cz>
Sat, 4 Aug 2007 01:09:12 +0000 (03:09 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Sat, 4 Aug 2007 01:09:12 +0000 (01:09 +0000)
* 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

gcc/ChangeLog
gcc/cfgloop.c
gcc/cfgloop.h
gcc/cfgloopanal.c
gcc/cfgloopmanip.c
gcc/loop-init.c
gcc/tree-cfg.c
gcc/tree-cfgcleanup.c
gcc/tree-ssa-loop-manip.c
gcc/tree-ssa-threadupdate.c

index b2bff86280959d9a6212064ff23f0a8534a9b07e..33211ce682e39f120872db815374a273f5a8186a 100644 (file)
@@ -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
index 411eb8eef46130e3d545a08d760866159df77b06..fd26d5dc05dd95adb0c01871fae211bcf8ee4ba2 100644 (file)
@@ -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)
index 903672dfcf96a20890eb158f114a1657180c6352..791dabf39891bab21398162676fa777bb6e2cdb3 100644 (file)
@@ -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.  */
index e1ef68d19260b5ac2c7660abbcd2c7cfff8b2853..13b674aaecbe32c5a29750bfdefda4e4c14db784 100644 (file)
@@ -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.  */
index 595d586038649cdc5bfe97f780faf3e3bea341ba..c66dfd47f8a5d4823c96bbac3a201d6a770bcaac 100644 (file)
@@ -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)
index 3bdafdaab8ba39f984bc038c02dfb9167c25a8b9..af62a31a9b8bc96b11a9f4b94a50a9f58a8aebf6 100644 (file)
@@ -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);
index f124c9a436fd05e7acf27bfd615b2c69a847f608..0c6c56a5918c853e052300831a64e107a6ae9571 100644 (file)
@@ -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)
index bd2523bf7e6b72e069cce225d358bd1dd73088f6..bcae4488dc122d203243092b529c4276dea3fa72 100644 (file)
@@ -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;
index 6faac9be3bb17812af8a42db0c7619619ca57f63..2ac9d1bdb6321c4a16c4d04783b2f521861c9942 100644 (file)
@@ -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
index a626cdd764898ad290c39cfeb61c7bc1b0a2d2d2..e6fa4f68f8b8d09b43c50b16f7ca5e1ad575d9b5 100644 (file)
@@ -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;
 }
This page took 0.149098 seconds and 5 git commands to generate.