https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106896
--- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Originally to_sreal_frquency was intended to work both inter-procedurally and
intra-procedurally. However in such setup there are side cases that can not be
solved without knowing the corresponding entry_bb_counts which are not known to
the function.
Inspecting existing uses of to_sreal_frequency it is used intra-procedurally
only. In that case it makes sense to implement it same way as probability_in
which is done by the following patch:
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;
}