public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6652] Fix overactive sanity check in profile_count::to_sreal_scale
@ 2023-03-14 8:11 Jan Hubicka
0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2023-03-14 8:11 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:5159a1f1e91e03d4b82808a0062697318232543f
commit r13-6652-g5159a1f1e91e03d4b82808a0062697318232543f
Author: Jan Hubicka <jh@suse.cz>
Date: Tue Mar 14 09:10:35 2023 +0100
Fix overactive sanity check in profile_count::to_sreal_scale
As discussed in the PR log, profile_count::to_cgraph_frequency was originally
intended to work across function boundary and has some extra logic and sanity
check for that. It is used only within single function and with current
API it can not really work well globally, so this patch synchronizes its
implementation with probability_in which does similar job but to determine
relative probability.
gcc/ChangeLog:
2023-03-14 Jan Hubicka <hubicka@ucw.cz>
PR tree-optimization/106896
* profile-count.cc (profile_count::to_sreal_scale): Synchronize
implementatoin with probability_in; avoid some asserts.
Diff:
---
gcc/profile-count.cc | 34 +++++++++++-----------------------
1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/gcc/profile-count.cc b/gcc/profile-count.cc
index d05fef3fb00..16585045f8e 100644
--- a/gcc/profile-count.cc
+++ b/gcc/profile-count.cc
@@ -325,6 +325,13 @@ profile_count::to_cgraph_frequency (profile_count entry_bb_count) const
sreal
profile_count::to_sreal_scale (profile_count in, bool *known) const
{
+ if (*this == zero ()
+ && !(in == zero ()))
+ {
+ if (known)
+ *known = true;
+ return 0;
+ }
if (!initialized_p () || !in.initialized_p ())
{
if (known)
@@ -333,32 +340,13 @@ profile_count::to_sreal_scale (profile_count in, bool *known) const
}
if (known)
*known = true;
- /* 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 ());
- if (*this == zero ())
- return 0;
- if (m_val == in.m_val)
+ if (*this == in)
return 1;
gcc_checking_assert (compatible_p (in));
-
+ if (m_val == in.m_val)
+ return 1;
if (!in.m_val)
- {
- if (!m_val)
- return 1;
- return m_val * 4;
- }
+ return m_val * 4;
return (sreal)m_val / (sreal)in.m_val;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-14 8:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-14 8:11 [gcc r13-6652] Fix overactive sanity check in profile_count::to_sreal_scale Jan Hubicka
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).