From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7840) id CE2463858016; Tue, 27 Sep 2022 23:47:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CE2463858016 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664322423; bh=fOVlocpsSP3VRB71q6ADDVx4gs4ODE3jy7+ZUbIqHGo=; h=From:To:Subject:Date:From; b=Q7psoGTpgR353M4EZP2Jw5+UOB/mxNOdoCfK5KKQspD31SjtcDl4zc9U6TTrBbwAB LEmEAOnKVuFL/nRhZC7BDP6L/qiIMsgToWDwWeHNiSqPsprTOBeSTa5COsnZ7QitYU RAgvA8Ac1GeLIVi3gXXwhutgI8G1bXo8x+bbFYOs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eugene Rozenfeld To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2906] Fix profile count comparison. X-Act-Checkin: gcc X-Git-Author: Eugene Rozenfeld X-Git-Refname: refs/heads/master X-Git-Oldrev: 772d532e0ba1e4b22c2b7d576e14b34ee929c093 X-Git-Newrev: 6bf473089f3c0c6ecf101f87f705618b1707fa82 Message-Id: <20220927234703.CE2463858016@sourceware.org> Date: Tue, 27 Sep 2022 23:47:03 +0000 (GMT) List-Id: https://gcc.gnu.org/g:6bf473089f3c0c6ecf101f87f705618b1707fa82 commit r13-2906-g6bf473089f3c0c6ecf101f87f705618b1707fa82 Author: Eugene Rozenfeld Date: Thu Sep 22 18:12:01 2022 -0700 Fix profile count comparison. The comparison was incorrect when the counts weren't PRECISE. For example, crossmodule-indir-call-topn-1.c was failing with AutoFDO: when count_sum is 0 with quality AFDO, count_sum > profile_count::zero() evaluates to true. Taking that branch then leads to an assert in the call to to_sreal(). Tested on x86_64-pc-linux-gnu. gcc/ChangeLog: * ipa-cp.cc (good_cloning_opportunity_p): Fix profile count comparison. Diff: --- gcc/ipa-cp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 543a9334e2c..66bba71c068 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -3338,9 +3338,9 @@ good_cloning_opportunity_p (struct cgraph_node *node, sreal time_benefit, ipa_node_params *info = ipa_node_params_sum->get (node); int eval_threshold = opt_for_fn (node->decl, param_ipa_cp_eval_threshold); - if (count_sum > profile_count::zero ()) + if (count_sum.nonzero_p ()) { - gcc_assert (base_count > profile_count::zero ()); + gcc_assert (base_count.nonzero_p ()); sreal factor = count_sum.probability_in (base_count).to_sreal (); sreal evaluation = (time_benefit * factor) / size_cost; evaluation = incorporate_penalties (node, info, evaluation);