From: Jan Hubicka Date: Thu, 3 Jul 2025 10:00:05 +0000 (+0200) Subject: Make inliner loop hints more agressive X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d52b0327a17f5ed12038bd83002627aac5b4b944;p=thirdparty%2Fgcc.git Make inliner loop hints more agressive This patch makes loop inline hints more agressive. If we know iteration count or stride, we currently assume improvement in time relative to preheader count. I changed it to header count, since this knowledge is supposed to likely help unrolling and vectorizing which brings benefits relative to that. * ipa-fnsummary.cc (analyze_function_body): For loop heuristics use header count instead of preheader count. --- diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc index 4c062fe8a0e..48343a76968 100644 --- a/gcc/ipa-fnsummary.cc +++ b/gcc/ipa-fnsummary.cc @@ -3236,8 +3236,8 @@ analyze_function_body (struct cgraph_node *node, bool early) if (!loop->header->aux) continue; - profile_count phdr_count = loop_preheader_edge (loop)->count (); - sreal phdr_freq = phdr_count.to_sreal_scale (entry_count); + profile_count hdr_count = loop->header->count; + sreal hdr_freq = hdr_count.to_sreal_scale (entry_count); bb_predicate = *(ipa_predicate *)loop->header->aux; auto_vec exits = get_loop_exit_edges (loop); @@ -3257,7 +3257,7 @@ analyze_function_body (struct cgraph_node *node, bool early) loop_iterations &= will_be_nonconstant; } add_freqcounting_predicate (&s->loop_iterations, loop_iterations, - phdr_freq, max_loop_predicates); + hdr_freq, max_loop_predicates); } /* To avoid quadratic behavior we analyze stride predicates only @@ -3268,8 +3268,8 @@ analyze_function_body (struct cgraph_node *node, bool early) { ipa_predicate loop_stride = true; basic_block *body = get_loop_body (loop); - profile_count phdr_count = loop_preheader_edge (loop)->count (); - sreal phdr_freq = phdr_count.to_sreal_scale (entry_count); + profile_count hdr_count = loop->header->count; + sreal hdr_freq = hdr_count.to_sreal_scale (entry_count); for (unsigned i = 0; i < loop->num_nodes; i++) { gimple_stmt_iterator gsi; @@ -3309,7 +3309,7 @@ analyze_function_body (struct cgraph_node *node, bool early) } } add_freqcounting_predicate (&s->loop_strides, loop_stride, - phdr_freq, max_loop_predicates); + hdr_freq, max_loop_predicates); free (body); } scev_finalize ();