From patchwork Thu Nov 28 15:47:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1202152 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-514779-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="U3xrEh8U"; 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 47P29457sjz9s7T for ; Fri, 29 Nov 2019 02:48:08 +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=mwKtyO3Bj7F1NiYO8NVm4WJWpk3VEBfuM7UjuOopoAShGgHymoPl2 1DgOBwXmaXkg/YAbz6w4HiRUtj6prufirytlSV8gJgw5Kqb3SQ0qw7eLlAOPva18 sC7ybzKncLyKpaPKoJ9+ZA9boGw4czRsqVq0aTtb5K9I4UL2IWzeNE= 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=0PQ3QoJpABYJyeHR0DQdGbzKw+0=; b=U3xrEh8UW4UKkDdbocoi aX5aMZR1+9uA+e6eUkYgRbNZhoA4Iaj6yVL92BM3aL/iFDs83MQ4tlMgotPHvmTB aFh0CZSxHK0vPgy/zU5tgpnfiPl+fj8IB7V9oyIYznVU9ewcQFBBpYDKG9U2MTyG FnlGx0OAuAIB3IljieeO5Y0= Received: (qmail 77848 invoked by alias); 28 Nov 2019 15:48:00 -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 77824 invoked by uid 89); 28 Nov 2019 15:48:00 -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=MAX, MIN, profiles, quality 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 15:47:59 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 23753280822; Thu, 28 Nov 2019 16:47:57 +0100 (CET) Date: Thu, 28 Nov 2019 16:47:57 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix profile_count::max and profile_count::apply_scale WRT counts of different types Message-ID: <20191128154757.nvxyebitpxfyv6am@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, profile_count::max and profile_count::apply_scale and two functions that needs to work with pairs of counters from different functions (first is used to obtain overall statistics used by e.g. inliner and profile_count::apply_scale is used to scale function profile when inline clones are created). profile_count::max needs to simply preffer global counts over local which is implemented to converting to IPA. profile_count::apply_scale needs to be careful about quality updates. If NUM is GUESSED_GLOBAL0 or GUESSED_GLOBAL0_ADJUSTED the result needs to be of same type and if NUM is other IPA count the result needs to be IPA too. Bootstrapped/regtested x86_64-linux, will commit it shortly after testing on Firefox. * profile-count.h (profile_count::max): Work on profiles of different type. (profile_count::apply_scale): Be sure that ret is not local or global0 type if num is global. Index: profile-count.h =================================================================== --- profile-count.h (revision 278811) +++ profile-count.h (working copy) @@ -992,6 +992,14 @@ public: profile_count max (profile_count other) const { + profile_count val = *this; + + /* Always prefer nonzero IPA counts over local counts. */ + if (ipa ().nonzero_p () || other.ipa ().nonzero_p ()) + { + val = ipa (); + other = other.ipa (); + } if (!initialized_p ()) return other; if (!other.initialized_p ()) @@ -1001,8 +1009,8 @@ public: if (other == zero ()) return *this; gcc_checking_assert (compatible_p (other)); - if (m_val < other.m_val || (m_val == other.m_val - && m_quality < other.m_quality)) + if (val.m_val < other.m_val || (m_val == other.m_val + && val.m_quality < other.m_quality)) return other; return *this; } @@ -1075,8 +1083,11 @@ public: ret.m_val = MIN (val, max_count); ret.m_quality = MIN (MIN (MIN (m_quality, ADJUSTED), num.m_quality), den.m_quality); - if (num.ipa_p () && !ret.ipa_p ()) - ret.m_quality = MIN (num.m_quality, GUESSED); + /* Be sure that ret is not local if num is global. + Also ensure that ret is not global0 when num is global. */ + if (num.ipa_p ()) + ret.m_quality = MAX (num.m_quality, + num == num.ipa () ? GUESSED : num.m_quality); return ret; }