From patchwork Thu Nov 28 12:33:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1202025 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-514766-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mqGA6M4G"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47NxsB3HvGz9sNx for ; Thu, 28 Nov 2019 23:34:04 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=OWiwSuWOFDPVRAVkPTcN2Bz2S4CxdIXB3TwuwSXxdhsp9NK/kNLe0 32NOj9+7VaE0lxxGnT0nWr88fW9xMQNFkTNWDdXNWOdZQ4/CccgWTQejG90ep5OH BvvPvo+WvjV7KHCWXAQ3q8d8zZsVkUNNq3opkl+ui+nHCKplnN3hNk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=uCQEoU5v6/Xn8k9e9I1odoNEMPk=; b=mqGA6M4GyjqEU78N033x exePdO02M48ty2qo1+8zzl9M+ffudeACcfh1zpQomnaicyTu45rcpp/6wP8byTVe kmSPf4pwR5tn9RZluHeM9yzQbRVJ9c/fEWx++N0fdp7keg07DCFV+FJrCHbhIMAT wViJRCINd7sO2vVEIfKbYXs= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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 13:33:51 +0100 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-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) 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);