]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* predict.c (tree_estimate_probability_bb): Add LOCAL_ONLY.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Jun 2017 08:07:31 +0000 (08:07 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Jun 2017 08:07:31 +0000 (08:07 +0000)
(tree_guess_outgoing_edge_probabilities): New.
* predict.h (tree_guess_outgoing_edge_probabilities): Declare.
* tree-cfg.c (gimple_find_sub_bbs): Propagate profile.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248912 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/predict.c
gcc/predict.h
gcc/tree-cfg.c

index 8a5960f7efbc94e00e7409cdea33a77a3c1e2cba..7d6eb885a67cb4a437a2957914f730927b4e5991 100644 (file)
@@ -1,3 +1,10 @@
+2017-06-06  Jan Hubicka  <hubicka@ucw.cz>
+
+       * predict.c (tree_estimate_probability_bb): Add LOCAL_ONLY.
+       (tree_guess_outgoing_edge_probabilities): New.
+       * predict.h (tree_guess_outgoing_edge_probabilities): Declare.
+       * tree-cfg.c (gimple_find_sub_bbs): Propagate profile.
+
 2017-06-06  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-split.c (split_function): Initialize return bb profile.
index 8eb28634b2feaf83197328b07f93b5869c9768c0..2dbe3afa48ba49a6e38b9d5269605939eeafcc20 100644 (file)
@@ -2665,10 +2665,11 @@ assert_is_empty (const_basic_block const &, edge_prediction *const &value,
   return false;
 }
 
-/* Predict branch probabilities and estimate profile for basic block BB.  */
+/* Predict branch probabilities and estimate profile for basic block BB.
+   When LOCAL_ONLY is set do not use any global properties of CFG.  */
 
 static void
-tree_estimate_probability_bb (basic_block bb)
+tree_estimate_probability_bb (basic_block bb, bool local_only)
 {
   edge e;
   edge_iterator ei;
@@ -2742,6 +2743,7 @@ tree_estimate_probability_bb (basic_block bb)
       /* Look for block we are guarding (ie we dominate it,
         but it doesn't postdominate us).  */
       if (e->dest != EXIT_BLOCK_PTR_FOR_FN (cfun) && e->dest != bb
+         && !local_only
          && dominated_by_p (CDI_DOMINATORS, e->dest, e->src)
          && !dominated_by_p (CDI_POST_DOMINATORS, e->src, e->dest))
        {
@@ -2800,7 +2802,7 @@ tree_estimate_probability (bool dry_run)
     predict_loops ();
 
   FOR_EACH_BB_FN (bb, cfun)
-    tree_estimate_probability_bb (bb);
+    tree_estimate_probability_bb (bb, false);
 
   FOR_EACH_BB_FN (bb, cfun)
     combine_predictions_for_bb (bb, dry_run);
@@ -2816,6 +2818,19 @@ tree_estimate_probability (bool dry_run)
   free_dominance_info (CDI_POST_DOMINATORS);
   remove_fake_exit_edges ();
 }
+
+/* Set edge->probability for each successor edge of BB.  */
+void
+tree_guess_outgoing_edge_probabilities (basic_block bb)
+{
+  bb_predictions = new hash_map<const_basic_block, edge_prediction *>;
+  tree_estimate_probability_bb (bb, true);
+  combine_predictions_for_bb (bb, false);
+  if (flag_checking)
+    bb_predictions->traverse<void *, assert_is_empty> (NULL);
+  delete bb_predictions;
+  bb_predictions = NULL;
+}
 \f
 /* Predict edges to successors of CUR whose sources are not postdominated by
    BB by PRED and recurse to all postdominators.  */
index d8ef0ab6c42727e2c181b39cd2310fef0f7b1d53..1441fa4d8eb86cdc8fcfebe7f532133656c5ba28 100644 (file)
@@ -83,6 +83,7 @@ extern void remove_predictions_associated_with_edge (edge);
 extern void predict_edge_def (edge, enum br_predictor, enum prediction);
 extern void invert_br_probabilities (rtx);
 extern void guess_outgoing_edge_probabilities (basic_block);
+extern void tree_guess_outgoing_edge_probabilities (basic_block);
 extern void tree_estimate_probability (bool);
 extern void handle_missing_profiles (void);
 extern bool counts_to_freqs (void);
index 286cc79647adeb0b083d699fd800cee87fe3bb01..1d5271a085c688de173794123121b78cadb2085a 100644 (file)
@@ -1048,10 +1048,27 @@ gimple_find_sub_bbs (gimple_seq seq, gimple_stmt_iterator *gsi)
   while (bb != afterbb)
     {
       struct omp_region *cur_region = NULL;
+      profile_count cnt = profile_count::zero ();
+      int freq = 0;
+
       int cur_omp_region_idx = 0;
       int mer = make_edges_bb (bb, &cur_region, &cur_omp_region_idx);
       gcc_assert (!mer && !cur_region);
       add_bb_to_loop (bb, afterbb->loop_father);
+
+      edge e;
+      edge_iterator ei;
+      FOR_EACH_EDGE (e, ei, bb->preds)
+       {
+         cnt += e->count;
+         freq += EDGE_FREQUENCY (e);
+       }
+      bb->count = cnt;
+      bb->frequency = freq;
+      tree_guess_outgoing_edge_probabilities (bb);
+      FOR_EACH_EDGE (e, ei, bb->succs)
+       e->count = bb->count.apply_probability (e->probability);
+
       bb = bb->next_bb;
     }
   return true;