]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa-inline.h (INLINE_HINT_known_hot): New hint.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 18 Apr 2014 19:36:01 +0000 (21:36 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 18 Apr 2014 19:36:01 +0000 (19:36 +0000)
* ipa-inline.h (INLINE_HINT_known_hot): New hint.
* ipa-inline-analysis.c (dump_inline_hints): Dump it.
(do_estimate_edge_time): Compute it.
* ipa-inline.c (want_inline_small_function_p): Bypass
INLINE_INSNS_AUTO/SINGLE limits for calls that are known
to be hot.

From-SVN: r209523

gcc/ChangeLog
gcc/ipa-inline-analysis.c
gcc/ipa-inline.c
gcc/ipa-inline.h

index a7d1c9df32f7ca3c04ff7b5c974ef1145b8192a1..5221338c22da268d1c1a17838488e7ac4d5132d2 100644 (file)
@@ -1,3 +1,12 @@
+2014-04-18  Jan Hubicka  <hubicka@ucw.cz>
+
+       * ipa-inline.h (INLINE_HINT_known_hot): New hint.
+       * ipa-inline-analysis.c (dump_inline_hints): Dump it.
+       (do_estimate_edge_time): Compute it.
+       * ipa-inline.c (want_inline_small_function_p): Bypass
+       INLINE_INSNS_AUTO/SINGLE limits for calls that are known
+       to be hot.
+
 2014-04-18  Jan Hubicka  <hubicka@ucw.cz>
 
        * ipa-inline.c (spec_rem): New static variable.
index c471e0cd899dfb917b0a4f9102802a6b2464a126..dfe305810fc5c392bc072da2a1a56c627f8ca016 100644 (file)
@@ -671,6 +671,11 @@ dump_inline_hints (FILE *f, inline_hints hints)
       hints &= ~INLINE_HINT_array_index;
       fprintf (f, " array_index");
     }
+  if (hints & INLINE_HINT_known_hot)
+    {
+      hints &= ~INLINE_HINT_known_hot;
+      fprintf (f, " known_hot");
+    }
   gcc_assert (!hints);
 }
 
@@ -3666,6 +3671,17 @@ do_estimate_edge_time (struct cgraph_edge *edge)
                                &known_aggs);
   estimate_node_size_and_time (callee, clause, known_vals, known_binfos,
                               known_aggs, &size, &min_size, &time, &hints, es->param);
+
+  /* When we have profile feedback, we can quite safely identify hot
+     edges and for those we disable size limits.  Don't do that when
+     probability that caller will call the callee is low however, since it
+     may hurt optimization of the caller's hot path.  */
+  if (edge->count && cgraph_maybe_hot_edge_p (edge)
+      && (edge->count * 2
+          > (edge->caller->global.inlined_to
+            ? edge->caller->global.inlined_to->count : edge->caller->count)))
+    hints |= INLINE_HINT_known_hot;
+
   known_vals.release ();
   known_binfos.release ();
   known_aggs.release ();
index 1b7a74e0745f3fb507b05744a624a37241ef5fc5..65e653320ad42418d7268ff093b41384749ad550 100644 (file)
@@ -578,18 +578,21 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
      inline cnadidate.  At themoment we allow inline hints to
      promote non-inline function to inline and we increase
      MAX_INLINE_INSNS_SINGLE 16fold for inline functions.  */
-  else if (!DECL_DECLARED_INLINE_P (callee->decl)
+  else if ((!DECL_DECLARED_INLINE_P (callee->decl)
+          && (!e->count || !cgraph_maybe_hot_edge_p (e)))
           && inline_summary (callee)->min_size - inline_edge_summary (e)->call_stmt_size
              > MAX (MAX_INLINE_INSNS_SINGLE, MAX_INLINE_INSNS_AUTO))
     {
       e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
       want_inline = false;
     }
-  else if (DECL_DECLARED_INLINE_P (callee->decl)
+  else if ((DECL_DECLARED_INLINE_P (callee->decl) || e->count)
           && inline_summary (callee)->min_size - inline_edge_summary (e)->call_stmt_size
              > 16 * MAX_INLINE_INSNS_SINGLE)
     {
-      e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
+      e->inline_failed = (DECL_DECLARED_INLINE_P (callee->decl)
+                         ? CIF_MAX_INLINE_INSNS_SINGLE_LIMIT
+                         : CIF_MAX_INLINE_INSNS_AUTO_LIMIT);
       want_inline = false;
     }
   else
@@ -606,6 +609,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
               && growth >= MAX_INLINE_INSNS_SINGLE
               && ((!big_speedup
                    && !(hints & (INLINE_HINT_indirect_call
+                                 | INLINE_HINT_known_hot
                                  | INLINE_HINT_loop_iterations
                                  | INLINE_HINT_array_index
                                  | INLINE_HINT_loop_stride)))
@@ -630,6 +634,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
         inlining given function is very profitable.  */
       else if (!DECL_DECLARED_INLINE_P (callee->decl)
               && !big_speedup
+              && !(hints & INLINE_HINT_known_hot)
               && growth >= ((hints & (INLINE_HINT_indirect_call
                                       | INLINE_HINT_loop_iterations
                                       | INLINE_HINT_array_index
index 8ee075f93000116b4a8d46c097f41c8d2c69fd9b..1e9ff4ca0a827090665cf4317801245827111c18 100644 (file)
@@ -68,7 +68,9 @@ enum inline_hints_vals {
   INLINE_HINT_cross_module = 64,
   /* If array indexes of loads/stores become known there may be room for
      further optimization.  */
-  INLINE_HINT_array_index = 128
+  INLINE_HINT_array_index = 128,
+  /* We know that the callee is hot by profile.  */
+  INLINE_HINT_known_hot = 256
 };
 typedef int inline_hints;