]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use profile_proability for...
authorJan Hubicka <hubicka@ucw.cz>
Sun, 16 Jul 2017 18:25:26 +0000 (20:25 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 16 Jul 2017 18:25:26 +0000 (18:25 +0000)
* tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use
profile_proability for scalling.
* scale_profile_for_vect_loop.c (scale_profile_for_vect_loop): Likewise.

From-SVN: r250245

gcc/ChangeLog
gcc/tree-ssa-loop-manip.c
gcc/tree-vect-loop.c

index c6491ffa5b2946132f3be03d3328bd083c98e098..31979ed91b398022fca3fe4922eb639c1666d6f3 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-16  Jan Hubicka  <hubicka@ucw.cz>
+
+       * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): Use
+       profile_proability for scalling.
+       * scale_profile_for_vect_loop.c (scale_profile_for_vect_loop): Likewise.
+
 2017-07-16  Jan Hubicka  <hubicka@ucw.cz>
 
        * cgraph.c (cgraph_edge::redirect_call_stmt_to_caller): Cleanup.
index b2f5f16b52a14a6a72898fb5e3323d1cf52a81d2..5488044b18f5572fc27f8d752ee0bd7765b1cae5 100644 (file)
@@ -1212,7 +1212,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   gimple_stmt_iterator bsi;
   use_operand_p op;
   bool ok;
-  unsigned i, prob, prob_entry, scale_unrolled;
+  unsigned i;
+  profile_probability prob, prob_entry, scale_unrolled;
   profile_count freq_e, freq_h;
   gcov_type new_est_niter = niter_for_unrolled_loop (loop, factor);
   unsigned irr = loop_preheader_edge (loop)->flags & EDGE_IRREDUCIBLE_LOOP;
@@ -1224,9 +1225,10 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
 
   /* Let us assume that the unrolled loop is quite likely to be entered.  */
   if (integer_nonzerop (enter_main_cond))
-    prob_entry = REG_BR_PROB_BASE;
+    prob_entry = profile_probability::always ();
   else
-    prob_entry = PROB_UNROLLED_LOOP_ENTERED * REG_BR_PROB_BASE / 100;
+    prob_entry = profile_probability::guessed_always ()
+                       .apply_scale (PROB_UNROLLED_LOOP_ENTERED, 100);
 
   /* The values for scales should keep profile consistent, and somewhat close
      to correct.
@@ -1242,13 +1244,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
      by appropriate factors).  */
   scale_unrolled = prob_entry;
 
-  new_loop = loop_version (loop, enter_main_cond, NULL,
-                          profile_probability::from_reg_br_prob_base
-                                (prob_entry),
-                          profile_probability::from_reg_br_prob_base
-                                (REG_BR_PROB_BASE - prob_entry),
-                          profile_probability::from_reg_br_prob_base
-                               (scale_unrolled),
+  new_loop = loop_version (loop, enter_main_cond, NULL, prob_entry,
+                          prob_entry.invert (), scale_unrolled,
                           profile_probability::guessed_always (),
                           true);
   gcc_assert (new_loop != NULL);
@@ -1266,6 +1263,8 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
      1 / (1 - exit->probability).  */
   if (exit->probability.initialized_p ())
     scale_dominated_blocks_in_loop (loop, exit->src,
+                                   /* We are scaling up here so probability
+                                      does not fit.  */
                                    REG_BR_PROB_BASE,
                                    REG_BR_PROB_BASE
                                    - exit->probability.to_reg_br_prob_base ());
@@ -1289,9 +1288,7 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   new_nonexit->flags = EDGE_TRUE_VALUE;
   new_nonexit->count -= exit->count;
   if (new_nonexit->probability.initialized_p ())
-    scale_bbs_frequencies_int (&loop->latch, 1,
-                              new_nonexit->probability.to_reg_br_prob_base (),
-                              REG_BR_PROB_BASE);
+    scale_bbs_frequencies (&loop->latch, 1, new_nonexit->probability);
 
   old_entry = loop_preheader_edge (loop);
   new_entry = loop_preheader_edge (new_loop);
@@ -1388,16 +1385,12 @@ tree_transform_and_unroll_loop (struct loop *loop, unsigned factor,
   rest->frequency += EDGE_FREQUENCY (new_exit);
 
   new_nonexit = single_pred_edge (loop->latch);
-  if (new_nonexit->probability.initialized_p ())
-    prob = new_nonexit->probability.to_reg_br_prob_base ();
-  else
-    prob = 0;
+  prob = new_nonexit->probability;
   new_nonexit->probability = new_exit->probability.invert ();
   new_nonexit->count = exit_bb->count - new_exit->count;
-  if (prob > 0)
-    scale_bbs_frequencies_int (&loop->latch, 1,
-                              new_nonexit->probability.to_reg_br_prob_base (),
-                              prob);
+  prob = new_nonexit->probability / prob;
+  if (prob.initialized_p ())
+    scale_bbs_frequencies (&loop->latch, 1, prob);
 
   /* Finally create the new counter for number of iterations and add the new
      exit instruction.  */
index 8168f27080e59d8205e3bebeff325123ed89258b..6c18c8f8ecb07c32e7c312226991aafd995b7edc 100644 (file)
@@ -7222,13 +7222,11 @@ scale_profile_for_vect_loop (struct loop *loop, unsigned vf)
                                 .apply_scale (1, new_est_niter + 1);
 
   edge exit_l = single_pred_edge (loop->latch);
-  int prob = exit_l->probability.initialized_p ()
-            ? exit_l->probability.to_reg_br_prob_base () : 0;
+  profile_probability prob = exit_l->probability;
   exit_l->probability = exit_e->probability.invert ();
   exit_l->count = exit_bb->count - exit_e->count;
-  if (prob > 0)
-    scale_bbs_frequencies_int (&loop->latch, 1,
-                              exit_l->probability.to_reg_br_prob_base (), prob);
+  if (prob.initialized_p () && exit_l->probability.initialized_p ())
+    scale_bbs_frequencies (&loop->latch, 1, exit_l->probability / prob);
 }
 
 /* Function vect_transform_loop.