public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/106896] [13 Regression] ICE in to_sreal_scale, at profile-count.cc:339
Date: Mon, 12 Sep 2022 11:21:47 +0000	[thread overview]
Message-ID: <bug-106896-4-qBcktK2nlz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-106896-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106896

rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu.org

--- Comment #1 from rsandifo at gcc dot gnu.org <rsandifo at gcc dot gnu.org> ---
The problematic line is:

  return bb->count.to_sreal_scale (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count);

where bb->count is:

  {m_val = 0, m_quality = GUESSED_LOCAL}

and the entry block count is:

  {m_val = 0, m_quality = PRECISE}

So we fail the first assert here:

  /* Watch for cases where one count is IPA and other is not.  */
  if (in.ipa ().initialized_p ())
    {
      gcc_checking_assert (ipa ().initialized_p ());
      /* If current count is inter-procedurally 0 and IN is inter-procedurally
         non-zero, return 0.  */
      if (in.ipa ().nonzero_p ()
          && !ipa().nonzero_p ())
        return 0;
    }
  else
    /* We can handle correctly 0 IPA count within locally estimated
       profile, but otherwise we are lost and this should not happen.   */
    gcc_checking_assert (!ipa ().initialized_p () || !ipa ().nonzero_p ());

But ipa() says:

  /* Return variant of profile count which is always safe to compare
     across functions.  */
  profile_count ipa () const
    {
      if (m_quality > GUESSED_GLOBAL0_ADJUSTED)
        return *this;
      if (m_quality == GUESSED_GLOBAL0)
        return zero ();
      if (m_quality == GUESSED_GLOBAL0_ADJUSTED)
        return adjusted_zero ();
      return uninitialized ();
    }

So it feels like the ipa() in to_sreal_scale is a speculative
“could I compare this value across functions, if I had to?”.

The bb->count computation quoted above is deliberately intraprocedural
rather than interprocedural.  In that context it doesn't really seem
relevant that one of the values could be compared across functions,
since that isn't what we're doing.

What's the right fix here?

  parent reply	other threads:[~2022-09-12 11:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-09 14:12 [Bug tree-optimization/106896] New: " asolokha at gmx dot com
2022-09-12  7:43 ` [Bug tree-optimization/106896] " rguenth at gcc dot gnu.org
2022-09-12 11:21 ` rsandifo at gcc dot gnu.org [this message]
2022-09-12 14:13 ` [Bug tree-optimization/106896] [13 Regression] ICE in to_sreal_scale, at profile-count.cc:339 since r13-2288-g61c4c989034548f4 marxin at gcc dot gnu.org
2022-09-12 14:26 ` marxin at gcc dot gnu.org
2022-09-14 12:43 ` rsandifo at gcc dot gnu.org
2022-09-14 13:41 ` marxin at gcc dot gnu.org
2022-10-18  8:47 ` rguenth at gcc dot gnu.org
2022-10-26  9:07 ` rsandifo at gcc dot gnu.org
2022-12-19 23:25 ` pinskia at gcc dot gnu.org
2023-02-06 12:01 ` jakub at gcc dot gnu.org
2023-03-03 16:18 ` hubicka at gcc dot gnu.org
2023-03-06 10:34 ` hubicka at gcc dot gnu.org
2023-03-14  8:11 ` cvs-commit at gcc dot gnu.org
2023-03-14  8:12 ` hubicka at gcc dot gnu.org

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=bug-106896-4-qBcktK2nlz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).