tree-ssa-threadupdate.c (thread_through_all_blocks): Record that the loop structures...
authorZdenek Dvorak <ook@ucw.cz>
Wed, 1 Aug 2007 11:39:31 +0000 (13:39 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Wed, 1 Aug 2007 11:39:31 +0000 (11:39 +0000)
* tree-ssa-threadupdate.c (thread_through_all_blocks): Record that
the loop structures may need fixing.
* tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
New functions.
(cleanup_tree_cfg_loop): Removed.
(cleanup_tree_cfg): If loops need fixing, call repair_loop_structures.
* tree-predcom.c (tree_predictive_commoning): Return TODO_cleanup_cfg
instead of running cleanup_tree_cfg_loop.
* cfgloop.h (LOOPS_NEED_FIXUP): New constant.
* tree-flow.h (cleanup_tree_cfg_loop): Declaration removed.
(tree_predictive_commoning): Declaration changed.
* passes.c (execute_function_todo): Do not use cleanup_tree_cfg_loop.

From-SVN: r127118

gcc/ChangeLog
gcc/cfgloop.h
gcc/passes.c
gcc/tree-cfgcleanup.c
gcc/tree-flow.h
gcc/tree-predcom.c
gcc/tree-ssa-threadupdate.c

index 178b736c9f76199bfe87f65c7ce928ab1d88b926..46efc5ddf3c0da41ad2a07c49996577a7e654b30 100644 (file)
@@ -1,3 +1,18 @@
+2007-08-01  Zdenek Dvorak  <ook@ucw.cz>
+
+       * tree-ssa-threadupdate.c (thread_through_all_blocks): Record that
+       the loop structures may need fixing.
+       * tree-cfgcleanup.c (cleanup_tree_cfg_noloop, repair_loop_structures):
+       New functions.
+       (cleanup_tree_cfg_loop): Removed.
+       (cleanup_tree_cfg): If loops need fixing, call repair_loop_structures.
+       * tree-predcom.c (tree_predictive_commoning): Return TODO_cleanup_cfg
+       instead of running cleanup_tree_cfg_loop.
+       * cfgloop.h (LOOPS_NEED_FIXUP): New constant.
+       * tree-flow.h (cleanup_tree_cfg_loop): Declaration removed.
+       (tree_predictive_commoning): Declaration changed.
+       * passes.c (execute_function_todo): Do not use cleanup_tree_cfg_loop.
+
 2007-08-01  Zdenek Dvorak  <ook@ucw.cz>
 
        * doc/invoke.texi (l1-cache-size): Update documentation.
index b1ec4b52141d9ae2a15fc5cdfe6ff8586e683203..903672dfcf96a20890eb158f114a1657180c6352 100644 (file)
@@ -170,7 +170,8 @@ enum
   LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS = 4,
   LOOPS_HAVE_RECORDED_EXITS = 8,
   LOOPS_MAY_HAVE_MULTIPLE_LATCHES = 16,
-  LOOP_CLOSED_SSA = 32
+  LOOP_CLOSED_SSA = 32,
+  LOOPS_NEED_FIXUP = 64
 };
 
 #define LOOPS_NORMAL (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES \
index 9ec254f3808f3b5ddadc5cf0dedc96a66d1ad424..51517063d8fb7750a84f663fc687ec8c78d8d7d0 100644 (file)
@@ -891,12 +891,7 @@ execute_function_todo (void *data)
   /* Always cleanup the CFG before trying to update SSA.  */
   if (flags & TODO_cleanup_cfg)
     {
-      bool cleanup;
-
-      if (current_loops)
-       cleanup = cleanup_tree_cfg_loop ();
-      else
-       cleanup = cleanup_tree_cfg ();
+      bool cleanup = cleanup_tree_cfg ();
 
       if (cleanup && (cfun->curr_properties & PROP_ssa))
        flags |= TODO_remove_unused_locals;
index 00fed83b5442497cc8e865019d965009cf14a324..c35001c33e7c2978e5a3c0a95e01df74d146d3a3 100644 (file)
@@ -596,8 +596,8 @@ cleanup_tree_cfg_1 (void)
 /* Remove unreachable blocks and other miscellaneous clean up work.
    Return true if the flowgraph was modified, false otherwise.  */
 
-bool
-cleanup_tree_cfg (void)
+static bool
+cleanup_tree_cfg_noloop (void)
 {
   bool changed;
 
@@ -632,34 +632,47 @@ cleanup_tree_cfg (void)
 
   timevar_pop (TV_TREE_CLEANUP_CFG);
 
+  if (changed && current_loops)
+    current_loops->state |= LOOPS_NEED_FIXUP;
+
   return changed;
 }
 
-/* Cleanup cfg and repair loop structures.  */
+/* Repairs loop structures.  */
 
-bool
-cleanup_tree_cfg_loop (void)
+static void
+repair_loop_structures (void)
 {
-  bool changed = cleanup_tree_cfg ();
+  bitmap changed_bbs = BITMAP_ALLOC (NULL);
+  fix_loop_structure (changed_bbs);
 
-  if (changed && current_loops != NULL)
-    {
-      bitmap changed_bbs = BITMAP_ALLOC (NULL);
-      fix_loop_structure (changed_bbs);
+  /* 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)
+    rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
 
-      /* 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)
-       rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
-
-      BITMAP_FREE (changed_bbs);
+  BITMAP_FREE (changed_bbs);
 
 #ifdef ENABLE_CHECKING
-      verify_loop_structure ();
+  verify_loop_structure ();
 #endif
-      scev_reset ();
-    }
+  scev_reset ();
+
+  current_loops->state &= ~LOOPS_NEED_FIXUP;
+}
+
+/* Cleanup cfg and repair loop structures.  */
+
+bool
+cleanup_tree_cfg (void)
+{
+  bool changed = cleanup_tree_cfg_noloop ();
+
+  if (current_loops != NULL
+      && (current_loops->state & LOOPS_NEED_FIXUP))
+    repair_loop_structures ();
+
   return changed;
 }
 
index e3895d19fbf20f6f3c9c2ac93022555434981945..55bec44c27bdf1181e2eb5a9628925f33bd870c7 100644 (file)
@@ -783,7 +783,6 @@ void remove_edge_and_dominated_blocks (edge);
 /* In tree-cfgcleanup.c  */
 extern bitmap cfgcleanup_altered_bbs;
 extern bool cleanup_tree_cfg (void);
-extern bool cleanup_tree_cfg_loop (void);
 
 /* In tree-pretty-print.c.  */
 extern void dump_generic_bb (FILE *, basic_block, int, int);
@@ -975,7 +974,7 @@ unsigned int tree_unroll_loops_completely (bool);
 unsigned int tree_ssa_prefetch_arrays (void);
 unsigned int remove_empty_loops (void);
 void tree_ssa_iv_optimize (void);
-void tree_predictive_commoning (void);
+unsigned tree_predictive_commoning (void);
 
 bool number_of_iterations_exit (struct loop *, edge,
                                struct tree_niter_desc *niter, bool);
index caf0501af048f6c69bdaa3643d536d31541defe2..fcf42911d28ea50b4a7e85c32816b27a85c27852 100644 (file)
@@ -2582,12 +2582,13 @@ end: ;
 
 /* Runs predictive commoning.  */
 
-void
+unsigned
 tree_predictive_commoning (void)
 {
   bool unrolled = false;
   struct loop *loop;
   loop_iterator li;
+  unsigned ret = 0;
 
   initialize_original_copy_tables ();
   FOR_EACH_LOOP (li, loop, LI_ONLY_INNERMOST)
@@ -2598,7 +2599,9 @@ tree_predictive_commoning (void)
   if (unrolled)
     {
       scev_reset ();
-      cleanup_tree_cfg_loop ();
+      ret = TODO_cleanup_cfg;
     }
   free_original_copy_tables ();
+
+  return ret;
 }
index dfe1829a110ebef5592b84217e0f89bc9332f0c2..a626cdd764898ad290c39cfeb61c7bc1b0a2d2d2 100644 (file)
@@ -1076,6 +1076,9 @@ thread_through_all_blocks (bool may_peel_loop_headers)
   VEC_free (edge, heap, threaded_edges);
   threaded_edges = NULL;
 
+  if (retval)
+    current_loops->state |= LOOPS_NEED_FIXUP;
+
   return retval;
 }