https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81318

--- Comment #24 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #23)
> determine_unlikely_bbs is intended to propagate known to be cold bbs
> (profile_count::zero) rather than guessed_zero so it seems to do the job
> correctly here, because we decide to trust the cold attribute (I am still
> undecided if we don't want to invent unlikely attribute for that).
> 
> I will take a look why this leads to ICE on propagating frequencies.

Ok, so assuming we want to have profile_count::zero, then we assign the same to
all edges reaching the BB. And for outgoing edges we:

      FOR_EACH_EDGE (e, ei, bb->succs)
        if (!(e->count == profile_count::zero ())
            && unlikely_executed_edge_p (e))
          {
            if (dump_file && (dump_flags & TDF_DETAILS))
              fprintf (dump_file, "Edge %i->%i is locally unlikely\n",
                       bb->index, e->dest->index);
            e->count = profile_count::zero ();
          }

which fails because the edges is neither EH or FAKE edge.
So we should probably test when setting probabilities to:
diff --git a/gcc/predict.c b/gcc/predict.c
index 198fa919d74..a10e9991667 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -1291,7 +1291,8 @@ combine_predictions_for_bb (basic_block bb, bool dry_run)
     }
   clear_bb_predictions (bb);

-  if (!bb->count.initialized_p () && !dry_run)
+  if (!first->probability.initialized_p ()
+      && !second->probability.initialized_p() && !dry_run)
     {
       first->probability
         = profile_probability::from_reg_br_prob_base (combined_probability);

What do you think Honza?

Reply via email to