public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Eugene Rozenfeld <Eugene.Rozenfeld@microsoft.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	Jan Hubicka <hubicka@ucw.cz>
Subject: Re: [PATCH] Fix profile count comparison.
Date: Mon, 26 Sep 2022 09:51:04 +0200	[thread overview]
Message-ID: <CAFiYyc2kT_86g_mv0e9zF+HU=F6mM4LN1zQmB-Z0Y0MN5d-SQg@mail.gmail.com> (raw)
In-Reply-To: <CY5PR21MB3542E50C76592E21B7207AB491519@CY5PR21MB3542.namprd21.prod.outlook.com>

On Fri, Sep 23, 2022 at 8:53 PM Eugene Rozenfeld via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> 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.

OK

> gcc/ChangeLog:
>
>         * ipa-cp.cc (good_cloning_opportunity_p): Fix profile count comparison.
> ---
>  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);
> --
> 2.25.1

      reply	other threads:[~2022-09-26  7:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-23 18:53 Eugene Rozenfeld
2022-09-26  7:51 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc2kT_86g_mv0e9zF+HU=F6mM4LN1zQmB-Z0Y0MN5d-SQg@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=Eugene.Rozenfeld@microsoft.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).