]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make inliner loop hints more agressive
authorJan Hubicka <hubicka@ucw.cz>
Thu, 3 Jul 2025 10:00:05 +0000 (12:00 +0200)
committerJan Hubicka <hubicka@ucw.cz>
Thu, 3 Jul 2025 10:00:05 +0000 (12:00 +0200)
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.

gcc/ipa-fnsummary.cc

index 4c062fe8a0e286b07f98817d84d1b4d9671a34c9..48343a7696808f509ad25263ac5b5a66f7fe492d 100644 (file)
@@ -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 ();