predict.c (propagate_unlikely_bbs_forward): Break out from ...
authorJan Hubicka <hubicka@ucw.cz>
Wed, 19 Jul 2017 18:08:53 +0000 (20:08 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 19 Jul 2017 18:08:53 +0000 (18:08 +0000)
* predict.c (propagate_unlikely_bbs_forward): Break out from ...
(determine_unlikely_bbs): ... here.
* predict.h (propagate_unlikely_bbs_forward): Declare.
* cfgexpand.c (pass_expand::execute): Use it.
* bb-reorder.c (sanitize_hot_paths): Do not consider known to be
unlikely edges.
(find_rarely_executed_basic_blocks_and_crossing_edges): Use
propagate_unlikely_bbs_forward.

From-SVN: r250359

gcc/ChangeLog
gcc/predict.c

index 44b3ba9a54b5102839dcf7627a1feb40ab0dd1b1..746b08ecb2d9e4d8468174f879a327af0f9b5304 100644 (file)
@@ -1,3 +1,14 @@
+2017-07-19  Jan Hubicka  <hubicka@ucw.cz>
+
+       * predict.c (propagate_unlikely_bbs_forward): Break out from ...
+       (determine_unlikely_bbs): ... here.
+       * predict.h (propagate_unlikely_bbs_forward): Declare.
+       * cfgexpand.c (pass_expand::execute): Use it.
+       * bb-reorder.c (sanitize_hot_paths): Do not consider known to be
+       unlikely edges.
+       (find_rarely_executed_basic_blocks_and_crossing_edges): Use
+       propagate_unlikely_bbs_forward.
+
 2017-07-19  Jan Hubicka  <hubicka@ucw.cz>
 
        PR middle-end/81331
index 1e2e11d71f00e8b35cfbb7c3fb4b67d4d590e768..609c099d7b5cf2d519e7447400cba171475c571b 100644 (file)
@@ -3374,6 +3374,55 @@ expensive_function_p (int threshold)
   return false;
 }
 
+/* All basic blocks that are reachable only from unlikely basic blocks are
+   unlikely.  */
+
+void
+propagate_unlikely_bbs_forward (void)
+{
+  auto_vec<basic_block, 64> worklist;
+  basic_block bb;
+  edge_iterator ei;
+  edge e;
+
+  if (!(ENTRY_BLOCK_PTR_FOR_FN (cfun)->count == profile_count::zero ()))
+    {
+      ENTRY_BLOCK_PTR_FOR_FN (cfun)->aux = (void *)(size_t) 1;
+      worklist.safe_push (ENTRY_BLOCK_PTR_FOR_FN (cfun));
+
+      while (worklist.length () > 0)
+       {
+         bb = worklist.pop ();
+         FOR_EACH_EDGE (e, ei, bb->succs)
+           if (!(e->count == profile_count::zero ())
+               && !(e->dest->count == profile_count::zero ())
+               && !e->dest->aux)
+             {
+               e->dest->aux = (void *)(size_t) 1;
+               worklist.safe_push (e->dest);
+             }
+       }
+    }
+
+  FOR_ALL_BB_FN (bb, cfun)
+    {
+      if (!bb->aux)
+       {
+         if (!(bb->count == profile_count::zero ())
+             && (dump_file && (dump_flags & TDF_DETAILS)))
+           fprintf (dump_file,
+                    "Basic block %i is marked unlikely by forward prop\n",
+                    bb->index);
+         bb->count = profile_count::zero ();
+         bb->frequency = 0;
+          FOR_EACH_EDGE (e, ei, bb->succs)
+           e->count = profile_count::zero ();
+       }
+      else
+        bb->aux = NULL;
+    }
+}
+
 /* Determine basic blocks/edges that are known to be unlikely executed and set
    their counters to zero.
    This is done with first identifying obviously unlikely BBs/edges and then
@@ -3418,43 +3467,6 @@ determine_unlikely_bbs ()
       gcc_checking_assert (!bb->aux);
     }
 
-  if (!(ENTRY_BLOCK_PTR_FOR_FN (cfun)->count == profile_count::zero ()))
-    {
-      ENTRY_BLOCK_PTR_FOR_FN (cfun)->aux = (void *)(size_t) 1;
-      worklist.safe_push (ENTRY_BLOCK_PTR_FOR_FN (cfun));
-
-      while (worklist.length () > 0)
-       {
-         bb = worklist.pop ();
-         FOR_EACH_EDGE (e, ei, bb->succs)
-           if (!(e->count == profile_count::zero ())
-               && !(e->dest->count == profile_count::zero ())
-               && !e->dest->aux)
-             {
-               e->dest->aux = (void *)(size_t) 1;
-               worklist.safe_push (e->dest);
-             }
-       }
-    }
-
-  FOR_ALL_BB_FN (bb, cfun)
-    {
-      if (!bb->aux)
-       {
-         if (!(bb->count == profile_count::zero ())
-             && (dump_file && (dump_flags & TDF_DETAILS)))
-           fprintf (dump_file,
-                    "Basic block %i is marked unlikely by forward prop\n",
-                    bb->index);
-         bb->count = profile_count::zero ();
-         bb->frequency = 0;
-          FOR_EACH_EDGE (e, ei, bb->succs)
-           e->count = profile_count::zero ();
-       }
-      else
-        bb->aux = NULL;
-    }
-
   auto_vec<int, 64> nsuccs;
   nsuccs.safe_grow_cleared (last_basic_block_for_fn (cfun));
   FOR_ALL_BB_FN (bb, cfun)