]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fixes for profile count/probability maintenance
authorEugene Rozenfeld <erozen@microsoft.com>
Sat, 16 Sep 2023 01:12:47 +0000 (18:12 -0700)
committerEugene Rozenfeld <erozen@microsoft.com>
Mon, 9 Oct 2023 20:07:11 +0000 (13:07 -0700)
Verifier checks have recently been strengthened to check that
all counts and probabilities are initialized. The checks fired
during autoprofiledbootstrap build and this patch fixes it.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:
* auto-profile.cc (afdo_calculate_branch_prob): Fix count comparisons
* tree-vect-loop-manip.cc (vect_do_peeling): Guard against zero count
when scaling loop profile

gcc/auto-profile.cc
gcc/tree-vect-loop-manip.cc

index ff3b763945cfab15502d61468b79796a116ddbc4..e75b0469374c74026e53624e3bac951f3b6ab725 100644 (file)
@@ -1434,7 +1434,7 @@ afdo_calculate_branch_prob (bb_set *annotated_bb)
       else
         total_count += AFDO_EINFO (e)->get_count ();
     }
-    if (num_unknown_succ == 0 && total_count > profile_count::zero ())
+    if (num_unknown_succ == 0 && total_count.nonzero_p())
       {
        FOR_EACH_EDGE (e, ei, bb->succs)
          e->probability
@@ -1571,7 +1571,7 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
       DECL_SOURCE_LOCATION (current_function_decl));
   afdo_source_profile->mark_annotated (cfun->function_start_locus);
   afdo_source_profile->mark_annotated (cfun->function_end_locus);
-  if (max_count > profile_count::zero ())
+  if (max_count.nonzero_p())
     {
       /* Calculate, propagate count and probability information on CFG.  */
       afdo_calculate_branch_prob (&annotated_bb);
index 09641901ff1e5c03dd07ab6f85dd67288f940ea2..2608c286e5d5bb05a7f3d5ab26ca37c5f104632e 100644 (file)
@@ -3335,7 +3335,7 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
              free (bbs);
              free (original_bbs);
            }
-         else
+         else if (old_count.nonzero_p ())
            scale_loop_profile (epilog, guard_to->count.probability_in (old_count), -1);
 
          /* Only need to handle basic block before epilog loop if it's not