Fix count comparison in ipa-cp

Message ID CY5PR21MB35427E6C2EE445568BFA6BA4910A9@CY5PR21MB3542.namprd21.prod.outlook.com
State New
Headers
Series Fix count comparison in ipa-cp |

Commit Message

Eugene Rozenfeld Nov. 21, 2022, 9:26 p.m. UTC
  The existing comparison was incorrect for non-PRECISE counts
(e.g., AFDO): we could end up with a 0 base_count, which could
lead to asserts, e.g., in good_cloning_opportunity_p.

gcc/ChangeLog:

        * ipa-cp.cc (ipcp_propagate_stage): Fix profile count comparison.
---
 gcc/ipa-cp.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jeff Law Nov. 22, 2022, 8:02 p.m. UTC | #1
On 11/21/22 14:26, Eugene Rozenfeld via Gcc-patches wrote:
> The existing comparison was incorrect for non-PRECISE counts
> (e.g., AFDO): we could end up with a 0 base_count, which could
> lead to asserts, e.g., in good_cloning_opportunity_p.
>
> gcc/ChangeLog:
>
>          * ipa-cp.cc (ipcp_propagate_stage): Fix profile count comparison.

OK.  Probably somewhat painful to pull together a reliable test for 
this, right?


Jeff
  

Patch

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index d2bcd5e5e69..9df8b456759 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -4225,7 +4225,7 @@  ipcp_propagate_stage (class ipa_topo_info *topo)
 	for (cgraph_edge *cs = node->callees; cs; cs = cs->next_callee)
 	  {
 	    profile_count count = cs->count.ipa ();
-	    if (!(count > profile_count::zero ()))
+	    if (!count.nonzero_p ())
 	      continue;
 
 	    enum availability avail;