From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 394383858C54 for ; Wed, 8 Mar 2023 10:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 394383858C54 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 21B4C219F4; Wed, 8 Mar 2023 10:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1678271592; h=from:from:reply-to: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=Ef7RqZV1/9x07PhCn0GLXVTPte3qZtleNcFKNk4e12M=; b=vzOVhG7/RUyErOx7xXZ0ZDx/3S3KTH3Sw308bDoAYe7OhGHIDfBQuXKuzza3H9wTHEd/W1 ZPxXkonAswjwZ3q8ewRaaTeZWPypqbnNG8Rv9TmzdSauSd2iJj92vrfQQEfPqn7R1Z5xvW gBui7p4ihtLsaaMsbaKCyhqKr0g7/bA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1678271592; h=from:from:reply-to: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=Ef7RqZV1/9x07PhCn0GLXVTPte3qZtleNcFKNk4e12M=; b=LvWDZx7TwPwB/k18D1J+2SoKlX6/a9HBrPWi8E6a9LY1CM54JHfuVVN+FhchCzSn/R9wOe syppd2jgd0MDdlBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 141081391B; Wed, 8 Mar 2023 10:33:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CzL8A2hkCGQrYAAAMHmgww (envelope-from ); Wed, 08 Mar 2023 10:33:12 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: Re: [PATCH 2/2] ipa-cp: Improve updating behavior when profile counts have gone bad In-Reply-To: References: User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Wed, 08 Mar 2023 11:33:11 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_SOFTFAIL,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: Hello, I'd like to ping the patch below. Martin On Tue, Feb 21 2023, Martin Jambor wrote: > 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. > --- > 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