Hi,
ipa-cp cloning disables itself for all functions not passing opt_for_fn
(node->decl, optimize_size) which disables it for cold wrappers of hot
functions where we want to propagate.  Since we later want to time saved
to be considered hot, we do not need to make this early test.

The patch also fixes few other places where AFDO 0 disables ipa-cp.

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

        * ipa-cp.cc (cs_interesting_for_ipcp_p): Handle
        correctly GLOBAL0 afdo counts.
        (ipcp_cloning_candidate_p): Do not rule out nodes
        !node->optimize_for_size_p ().
        (good_cloning_opportunity_p): Handle afdo counts        
        as non-zero.
        (update_profiling_info):

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 75ea94f2ad8..480cf48786c 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -554,6 +554,7 @@ cs_interesting_for_ipcp_p (cgraph_edge *e)
   /* If we have zero IPA profile, still consider edge for cloning
      in case we do partial training.  */
   if (e->count.ipa ().initialized_p ()
+      && e->count.ipa ().quality () != AFDO
       && !opt_for_fn (e->callee->decl,flag_profile_partial_training))
     return false;
   return true;
@@ -617,7 +618,9 @@ ipcp_cloning_candidate_p (struct cgraph_node *node)
       return false;
     }
 
-  if (node->optimize_for_size_p ())
+  /* Do not use profile here since cold wrapper wrap
+     hot function.  */
+  if (opt_for_fn (node->decl, optimize_size))
     {
       if (dump_file)
        fprintf (dump_file, "Not considering %s for cloning; "
@@ -3391,9 +3394,10 @@ good_cloning_opportunity_p (struct cgraph_node *node, 
sreal time_benefit,
                            int size_cost, bool called_without_ipa_profile)
 {
   gcc_assert (count_sum.ipa () == count_sum);
+  if (count_sum.quality () == AFDO)
+    count_sum = count_sum.force_nonzero ();
   if (time_benefit == 0
       || !opt_for_fn (node->decl, flag_ipa_cp_clone)
-      || node->optimize_for_size_p ()
       /* If there is no call which was executed in profiling or where
         profile is missing, we do not want to clone.  */
       || (!called_without_ipa_profile && !count_sum.nonzero_p ()))

Reply via email to