From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EFA1B3858C52; Mon, 6 Mar 2023 10:34:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EFA1B3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678098868; bh=8pPPJSi/KRitX6w87tLYnJ26n7gy2ZMT9dxavsRPlYQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hgzQOKTKjOaozAPZ86HKxlpHmnJ7JDSGRQQFUNPTMO4utdJFMeRD8OItYMmsEd88p ltsGkTfwuIGO4T7zf3/s9DQekIbCaZqMASiCdDj+HhnpZV05G/VgzO2ys57Kp0NikU 5JgmA6Fu/7zKAVQSjTKoV4X9u3OVLVNQNhnFlaOs= From: "hubicka at gcc dot 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 since r13-2288-g61c4c989034548f4 Date: Mon, 06 Mar 2023 10:34:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106896 --- Comment #11 from Jan Hubicka --- Originally to_sreal_frquency was intended to work both inter-procedurally a= nd 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 know= n 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 =3D=3D zero () + && !(in =3D=3D zero ())) + { + if (known) + *known =3D 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 =3D 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-procedur= ally - non-zero, return 0. */ - if (in.ipa ().nonzero_p () - && !ipa().nonzero_p ()) - return 0; - } - else=20 - /* 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 =3D=3D zero ()) - return 0; - if (m_val =3D=3D in.m_val) + if (*this =3D=3D in) return 1; gcc_checking_assert (compatible_p (in)); - + if (m_val =3D=3D 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; }=