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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jamborm at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #6 from Martin Jambor <jamborm at gcc dot gnu.org> ---
The assert is bogus, the "new" division of unexplained counts in the
case of recursive functions so it can easily happen that what is left
is less than what we're trying to take away.  Having said that, there
are a few more issues with the function, chief among them not dropping
potentially guessed profiles to ipa.

I'm going to test the following:

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 4b8dedc0c51..5a6b41cf2d6 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -5093,22 +5093,24 @@ update_specialized_profile (struct cgraph_node
*new_node,
                            profile_count redirected_sum)
 { 
   struct cgraph_edge *cs;
-  profile_count new_node_count, orig_node_count = orig_node->count;
+  profile_count new_node_count, orig_node_count = orig_node->count.ipa ();

   if (dump_file)
     { 
       fprintf (dump_file, "    the sum of counts of redirected  edges is ");
       redirected_sum.dump (dump_file);
+      fprintf (dump_file, "\n    old ipa count of the original node is ");
+      orig_node_count.dump (dump_file);
       fprintf (dump_file, "\n");
     }
   if (!(orig_node_count > profile_count::zero ()))
     return;

-  gcc_assert (orig_node_count >= redirected_sum);
-  
   new_node_count = new_node->count;
   new_node->count += redirected_sum;
-  orig_node->count -= redirected_sum;
+  orig_node->count
+    = lenient_count_portion_handling (orig_node->count - redirected_sum,
+                                     orig_node);

   for (cs = new_node->callees; cs; cs = cs->next_callee)
     cs->count += cs->count.apply_scale (redirected_sum, new_node_count);

Reply via email to