From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 455433858C2D for ; Fri, 10 Mar 2023 17:24:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 455433858C2D Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 72AD528A0E5; Fri, 10 Mar 2023 18:24:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1678469052; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8JYu5xOXDK55dk9zZcXFSqt+b3RZ4Yuy+b/oDcQzq2o=; b=nrUT4cre+CFG7ggxWaDQIa4pmuySPGpTrwrTPIwich96Er32YZrYQbS8l9poO7XnPRqKCr NbXXePQOo16Uyal6dWnYXm3xhCVuLs65J9idpwuHcTspk1wE/hA6Jd5vnHBeOk77W3YeB9 yhJPJl10pqDXicNGxd/VzvXlGcjJzNQ= Date: Fri, 10 Mar 2023 18:24:12 +0100 From: Jan Hubicka To: Martin Jambor Cc: GCC Patches Subject: Re: [PATCH 2/2] ipa-cp: Improve updating behavior when profile counts have gone bad Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > Hi, > > Looking into the behavior of profile count updating in PR 107925, I > noticed that an option not considered possible was actually happening, > and - with the guesswork in place to distribute unexplained counts - > it simply can happen. Currently it is handled by dropping the counts > to local estimated zero, whereas it is probably better to leave the > count as they are but drop the category to GUESSED_GLOBAL0 - which is > what profile_count::combine_with_ipa_count in a similar case (or so I > hope :-) > > Profiled-LTO-bootstrapped and normally bootstrapped and tested on an > x86_64-linux. OK for master once stage1 opens up? Or perhaps even now? > > Thanks, > > Martin > > > gcc/ChangeLog: > > 2023-02-20 Martin Jambor > > PR ipa/107925 > * ipa-cp.cc (update_profiling_info): Drop counts of orig_node to > global0 instead of zeroing when it does not have as many counts as > it should. OK, thanks! Honza > --- > gcc/ipa-cp.cc | 29 ++++++++++++++++++++++------- > 1 file changed, 22 insertions(+), 7 deletions(-) > > diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc > index 5a6b41cf2d6..6477bb840e5 100644 > --- a/gcc/ipa-cp.cc > +++ b/gcc/ipa-cp.cc > @@ -4969,10 +4969,20 @@ update_profiling_info (struct cgraph_node *orig_node, > false); > new_sum = stats.count_sum; > > + bool orig_edges_processed = false; > if (new_sum > orig_node_count) > { > - /* TODO: Perhaps this should be gcc_unreachable ()? */ > - remainder = profile_count::zero ().guessed_local (); > + /* TODO: Profile has alreay gone astray, keep what we have but lower it > + to global0 category. */ > + remainder = orig_node->count.global0 (); > + > + for (cgraph_edge *cs = orig_node->callees; cs; cs = cs->next_callee) > + cs->count = cs->count.global0 (); > + for (cgraph_edge *cs = orig_node->indirect_calls; > + cs; > + cs = cs->next_callee) > + cs->count = cs->count.global0 (); > + orig_edges_processed = true; > } > else if (stats.rec_count_sum.nonzero_p ()) > { > @@ -5070,11 +5080,16 @@ update_profiling_info (struct cgraph_node *orig_node, > for (cgraph_edge *cs = new_node->indirect_calls; cs; cs = cs->next_callee) > cs->count = cs->count.apply_scale (new_sum, orig_new_node_count); > > - profile_count::adjust_for_ipa_scaling (&remainder, &orig_node_count); > - for (cgraph_edge *cs = orig_node->callees; cs; cs = cs->next_callee) > - cs->count = cs->count.apply_scale (remainder, orig_node_count); > - for (cgraph_edge *cs = orig_node->indirect_calls; cs; cs = cs->next_callee) > - cs->count = cs->count.apply_scale (remainder, orig_node_count); > + if (!orig_edges_processed) > + { > + profile_count::adjust_for_ipa_scaling (&remainder, &orig_node_count); > + for (cgraph_edge *cs = orig_node->callees; cs; cs = cs->next_callee) > + cs->count = cs->count.apply_scale (remainder, orig_node_count); > + for (cgraph_edge *cs = orig_node->indirect_calls; > + cs; > + cs = cs->next_callee) > + cs->count = cs->count.apply_scale (remainder, orig_node_count); > + } > > if (dump_file) > { > -- > 2.39.1 >