]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/48636 (Enable more inlining with -O2 and higher)
authorJan Hubicka <jh@suse.cz>
Thu, 8 Nov 2012 16:46:18 +0000 (17:46 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 8 Nov 2012 16:46:18 +0000 (16:46 +0000)
PR middle-end/48636
* ipa-inline.c (big_speedup_p): New function.
(want_inline_small_function_p): Use it.
(edge_badness): Dump it.
* params.def (inline-min-speedup): New parameter.
* doc/invoke.texi (inline-min-speedup): Document.

From-SVN: r193331

gcc/ChangeLog
gcc/doc/invoke.texi
gcc/ipa-inline.c
gcc/params.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/winline-3.c

index 2e98e1107c6d8b5dac524ca8506fdb3a6138f23f..b757503d8cb9b592a32032e84bbf4055e46f36ba 100644 (file)
@@ -1,3 +1,12 @@
+2012-11-08  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/48636
+       * ipa-inline.c (big_speedup_p): New function.
+       (want_inline_small_function_p): Use it.
+       (edge_badness): Dump it.
+       * params.def (inline-min-speedup): New parameter.
+       * doc/invoke.texi (inline-min-speedup): Document.
+
 2012-11-08  Martin Jambor  <mjambor@suse.cz>
 
        * ipa-prop.c (determine_known_aggregate_parts): Skip writes to
index f6d3a588809771b2ac45ce422dc710f056426b09..715f60adacf2cfcf0d192490636d3a7769e5e3f3 100644 (file)
@@ -8945,6 +8945,12 @@ by the compiler are investigated.  To those functions, a different
 be applied.
 The default value is 40.
 
+@item inline-min-speedup
+When estimated performance improvement of caller + callee runtime exceeds this
+threshold (in precent), the function can be inlined regardless the limit on
+@option{--param max-inline-insns-single} and @option{--param
+max-inline-insns-auto}.
+
 @item large-function-insns
 The limit specifying really large functions.  For functions larger than this
 limit after inlining, inlining is constrained by
index 4b705799855c52ad66536fe4576f2ca74eee4e04..fa3d4568c1ba5ff8dab66e36ddcda16f4da1e5fa 100644 (file)
@@ -493,6 +493,22 @@ compute_inlined_call_time (struct cgraph_edge *edge,
   return time;
 }
 
+/* Return true if the speedup for inlining E is bigger than
+   PARAM_MAX_INLINE_MIN_SPEEDUP.  */
+
+static bool
+big_speedup_p (struct cgraph_edge *e)
+{
+  gcov_type time = compute_uninlined_call_time (inline_summary (e->callee),
+                                               e);
+  gcov_type inlined_time = compute_inlined_call_time (e,
+                                                     estimate_edge_time (e));
+  if (time - inlined_time
+      > RDIV (time * PARAM_VALUE (PARAM_INLINE_MIN_SPEEDUP), 100))
+    return true;
+  return false;
+}
+
 /* Return true if we are interested in inlining small function.
    When REPORT is true, report reason to dump file.  */
 
@@ -514,6 +530,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
     {
       int growth = estimate_edge_growth (e);
       inline_hints hints = estimate_edge_hints (e);
+      bool big_speedup = big_speedup_p (e);
 
       if (growth <= 0)
        ;
@@ -521,6 +538,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
         hints suggests that inlining given function is very profitable.  */
       else if (DECL_DECLARED_INLINE_P (callee->symbol.decl)
               && growth >= MAX_INLINE_INSNS_SINGLE
+              && !big_speedup
               && !(hints & (INLINE_HINT_indirect_call
                             | INLINE_HINT_loop_iterations
                             | INLINE_HINT_loop_stride)))
@@ -574,6 +592,7 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
         Upgrade it to MAX_INLINE_INSNS_SINGLE when hints suggests that
         inlining given function is very profitable.  */
       else if (!DECL_DECLARED_INLINE_P (callee->symbol.decl)
+              && !big_speedup
               && growth >= ((hints & (INLINE_HINT_indirect_call
                                       | INLINE_HINT_loop_iterations
                                       | INLINE_HINT_loop_stride))
@@ -836,6 +855,8 @@ edge_badness (struct cgraph_edge *edge, bool dump)
               growth,
               edge_time);
       dump_inline_hints (dump_file, hints);
+      if (big_speedup_p (edge))
+       fprintf (dump_file, " big_speedup");
       fprintf (dump_file, "\n");
     }
 
index c801c6172942b8b77dbb082411f4909f247a30e1..42cf2eb31237471cf367c8fdd572947701c30b4c 100644 (file)
@@ -46,6 +46,11 @@ DEFPARAM (PARAM_PREDICTABLE_BRANCH_OUTCOME,
          "Maximal estimated outcome of branch considered predictable",
          2, 0, 50)
 
+DEFPARAM (PARAM_INLINE_MIN_SPEEDUP,
+         "inline-min-speedup",
+         "The minimal estimated speedup allowing inliner to ignore inline-insns-single and inline-isnsns-auto",
+         10, 0, 0)
+
 /* The single function inlining limit. This is the maximum size
    of a function counted in internal gcc instructions (not in
    real machine instructions) that is eligible for inlining
index e545ea7e801521d6e17ef1aaaaf08b510da958a7..e9d319bb7543525dd325f32e56da440faf7b88a9 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-08  Jan Hubicka  <jh@suse.cz>
+
+       PR middle-end/48636
+       * gcc.dg/winline-3.c: Update.
+
 2012-11-08  Martin Jambor  <mjambor@suse.cz>
 
        * gfortran.dg/ipcp-array-1.f90: New test.
index d586cba644a9fd5762d171522b6091240f5cfe31..fc12f573ab040be87cad0fc9843fb0a8e1271c7c 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-Winline -O2 --param max-inline-insns-single=1" } */
+/* { dg-options "-Winline -O2 --param max-inline-insns-single=1 --param inline-min-speedup=100" } */
 
 void big (void);
 inline int q(void) /* { dg-warning "max-inline-insns-single" "" } */