tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Avoid use of profile...
authorJan Hubicka <hubicka@ucw.cz>
Fri, 3 Jun 2016 17:00:19 +0000 (19:00 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 3 Jun 2016 17:00:19 +0000 (17:00 +0000)
* tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Avoid
use of profile unless profile status is PROFILE_READ.
* profile.c (compute_branch_probabilities): Set profile status
only after reporting predictor hitrates.

From-SVN: r237076

gcc/ChangeLog
gcc/profile.c
gcc/tree-ssa-loop-niter.c

index d52fa3d1ffe49b35f3b9c460de036da17781e2dd..068b874dd1788924178beceae86bfd02da770f93 100644 (file)
@@ -1,3 +1,10 @@
+2016-06-03  Jan Hubicka  <hubicka@ucw.cz>
+
+       * tree-ssa-loop-niter.c (estimate_numbers_of_iterations_loop): Avoid
+       use of profile unless profile status is PROFILE_READ.
+       * profile.c (compute_branch_probabilities): Set profile status
+       only after reporting predictor hitrates.
+
 2016-06-03  Joseph Myers  <joseph@codesourcery.com>
 
        PR target/71276
index 007379baa13ce046a6e2e42d060ff5e06c198f40..9925bb568c68c9c35b54e8a882dde8038e74c2f2 100644 (file)
@@ -826,8 +826,6 @@ compute_branch_probabilities (unsigned cfg_checksum, unsigned lineno_checksum)
        }
     }
   counts_to_freqs ();
-  profile_status_for_fn (cfun) = PROFILE_READ;
-  compute_function_frequency ();
 
   if (dump_file)
     {
@@ -1329,8 +1327,13 @@ branch_prob (void)
   values.release ();
   free_edge_list (el);
   coverage_end_function (lineno_checksum, cfg_checksum);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    report_predictor_hitrates ();
+  if (flag_branch_probabilities && profile_info)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       report_predictor_hitrates ();
+      profile_status_for_fn (cfun) = PROFILE_READ;
+      compute_function_frequency ();
+    }
 }
 \f
 /* Union find algorithm implementation for the basic blocks using
index e70e0a7e99a520dd50c1ef44502d197c9c3b8e54..78040364a97fbf1b7da023cfc426170ec52c3abe 100644 (file)
@@ -3757,10 +3757,12 @@ estimate_numbers_of_iterations_loop (struct loop *loop)
   maybe_lower_iteration_bound (loop);
 
   /* If we have a measured profile, use it to estimate the number of
-     iterations.  */
-  if (loop->header->count != 0)
+     iterations.  Explicitly check for profile status so we do not report
+     wrong prediction hitrates for guessed loop iterations heuristics.  */
+  if (loop->header->count != 0
+      && profile_status_for_fn (cfun) >= PROFILE_READ)
     {
-      gcov_type nit = expected_loop_iterations_unbounded (loop) + 1;
+      gcov_type nit = expected_loop_iterations_unbounded (loop);
       bound = gcov_type_to_wide_int (nit);
       record_niter_bound (loop, bound, true, false);
     }