From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D68263858D32 for ; Tue, 21 Feb 2023 14:42:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D68263858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass 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 9719634B3E; Tue, 21 Feb 2023 14:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1676990561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=COAVFI5z46w9Zf0Ei1imKNs0l0Zx3X9EFd2ksjghEyU=; b=WqkJ/P46vNPEgWJWjXDCO+eWJZfydUNDq8QRNrXvkjXP8pSE2ax9Y345BPO0Zbr7gWrnCT /WLjx7a1ETu5ARhKn79ocHK9OlLDodNFvEECGyIn2P/utjjGHU/itdU5T1deFRvbqTqAGo iX3dYgdrvRIgxPSNBxr5qFOsYtz6mKM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1676990561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=COAVFI5z46w9Zf0Ei1imKNs0l0Zx3X9EFd2ksjghEyU=; b=hiLcazTtCyglqI8DcxBkaQy+jsXSzZVlEPHxLAxvYNn43ZA0PfxD61o3VWtsOCIUNDbfJA oou/UNe4l3iYJ2DQ== 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 8A64E13223; Tue, 21 Feb 2023 14:42:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id fm6+IWHY9GP7WQAAMHmgww (envelope-from ); Tue, 21 Feb 2023 14:42:41 +0000 From: Martin Jambor To: GCC Patches Cc: Jan Hubicka Subject: [PATCH 1/2] ipa-cp: Fix various issues in update_specialized_profile (PR 107925) User-Agent: Notmuch/0.37 (https://notmuchmail.org) Emacs/28.2 (x86_64-suse-linux-gnu) Date: Tue, 21 Feb 2023 15:42:41 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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, the patch below fixes various issues in function update_specialized_profile. The main is removal of the assert which is bogus in the case of recursive cloning. The division of unexplained counts is guesswork, which then leads to updates of counts of recursive edges, which then can be redirected to the new clone and their count subtracted from the count and there simply may not be enough left in the count of the original node - especially when we clone a lot because of using --param ipa-cp-eval-threshold=1. The other issue was omission to drop the count of the original node to ipa count. And when calculating the remainder, we should use lenient_count_portion_handling to account for partial train runs. Finally, the patch adds dumping of the original count which I think is useful. Profiled-LTO-bootstrapped on its own and also normally bootstrapped and tested together with the subsequent patch on an x86_64-linux. OK for master and the 12 branch - assuming it is also affected? Thanks, Martin gcc/ChangeLog: 2023-02-17 Martin Jambor PR ipa/107925 * ipa-cp.cc (update_specialized_profile): Drop orig_node_count to ipa count, remove assert, lenient_count_portion_handling, dump also orig_node_count. --- gcc/ipa-cp.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 4b8dedc0c51..5a6b41cf2d6 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -5093,22 +5093,24 @@ update_specialized_profile (struct cgraph_node *new_node, profile_count redirected_sum) { struct cgraph_edge *cs; - profile_count new_node_count, orig_node_count = orig_node->count; + profile_count new_node_count, orig_node_count = orig_node->count.ipa (); if (dump_file) { fprintf (dump_file, " the sum of counts of redirected edges is "); redirected_sum.dump (dump_file); + fprintf (dump_file, "\n old ipa count of the original node is "); + orig_node_count.dump (dump_file); fprintf (dump_file, "\n"); } if (!(orig_node_count > profile_count::zero ())) return; - gcc_assert (orig_node_count >= redirected_sum); - new_node_count = new_node->count; new_node->count += redirected_sum; - orig_node->count -= redirected_sum; + orig_node->count + = lenient_count_portion_handling (orig_node->count - redirected_sum, + orig_node); for (cs = new_node->callees; cs; cs = cs->next_callee) cs->count += cs->count.apply_scale (redirected_sum, new_node_count); -- 2.39.1