https://gcc.gnu.org/g:d52b0327a17f5ed12038bd83002627aac5b4b944

commit r16-1969-gd52b0327a17f5ed12038bd83002627aac5b4b944
Author: Jan Hubicka <hubi...@ucw.cz>
Date:   Thu Jul 3 12:00:05 2025 +0200

    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:
---
 gcc/ipa-fnsummary.cc | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
index 4c062fe8a0e2..48343a769680 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<edge> 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 ();

Reply via email to