From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25651 invoked by alias); 28 Nov 2019 12:33:57 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25637 invoked by uid 89); 28 Nov 2019 12:33:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Nov 2019 12:33:54 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 02555280823; Thu, 28 Nov 2019 13:33:51 +0100 (CET) Date: Thu, 28 Nov 2019 12:55:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, mjambor@suse.cz Subject: Fix scaling in update_profiling_info Message-ID: <20191128123351.7ocfdzbsj2atwoli@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) X-SW-Source: 2019-11/txt/msg02559.txt.bz2 Hi, This patch fixes scaling in update_profiling_info. My understanding is that there is orig_node and new_node which have some counts that comes from cloning but real distribution of execution counts is determined by counting callers to new clone. This is new_sum. We thus want to scale orig_node to orig_node->count-new_sum and new_node to new_sum. Code seems to miss initialization of new_sum and updating of indirect calls. Also i do not see why new_node->count and orig_node->count are same (because orig_node can be updated multiple times) and thus I added code to save original new_node->count so scaling can be done properly. proiflebootstrapped/regtested x86_64. Martin, I would like you to take a look on this. Honza * ipa-cp.c (update_profiling_info): Fix scaling. Index: ipa-cp.c =================================================================== --- ipa-cp.c (revision 278778) +++ ipa-cp.c (working copy) @@ -4091,6 +4091,7 @@ update_profiling_info (struct cgraph_nod struct caller_statistics stats; profile_count new_sum, orig_sum; profile_count remainder, orig_node_count = orig_node->count; + profile_count orig_new_node_count = new_node->count; if (!(orig_node_count.ipa () > profile_count::zero ())) return; @@ -4128,15 +4129,20 @@ update_profiling_info (struct cgraph_nod remainder = orig_node_count.combine_with_ipa_count (orig_node_count.ipa () - new_sum.ipa ()); new_sum = orig_node_count.combine_with_ipa_count (new_sum); + new_node->count = new_sum; orig_node->count = remainder; - profile_count::adjust_for_ipa_scaling (&new_sum, &orig_node_count); + profile_count::adjust_for_ipa_scaling (&new_sum, &orig_new_node_count); for (cs = new_node->callees; cs; cs = cs->next_callee) - cs->count = cs->count.apply_scale (new_sum, orig_node_count); + cs->count = cs->count.apply_scale (new_sum, orig_new_node_count); + for (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 (cs = orig_node->callees; cs; cs = cs->next_callee) cs->count = cs->count.apply_scale (remainder, orig_node_count); + for (cs = orig_node->indirect_calls; cs; cs = cs->next_callee) + cs->count = cs->count.apply_scale (remainder, orig_node_count); if (dump_file) dump_profile_updates (orig_node, new_node);