public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Reduce inlining functions called once
@ 2021-12-03 12:20 Jan Hubicka
  0 siblings, 0 replies; only message in thread
From: Jan Hubicka @ 2021-12-03 12:20 UTC (permalink / raw)
  To: gcc-cvs

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

commit c9b22c0fb364a3b341ec797cc59ed31c3d5b0851
Author: Jan Hubicka <jh@suse.cz>
Date:   Fri Dec 3 13:19:53 2021 +0100

    Reduce inlining functions called once

Diff:
---
 gcc/ipa-inline.c | 47 ++++++++++++++++++++++++++++++-----------------
 gcc/params.opt   |  8 ++++++++
 2 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 012b326b5e9..3b3c250534f 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1091,20 +1091,30 @@ static bool
 check_callers (struct cgraph_node *node, void *has_hot_call)
 {
   struct cgraph_edge *e;
-   for (e = node->callers; e; e = e->next_caller)
-     {
-       if (!opt_for_fn (e->caller->decl, flag_inline_functions_called_once)
-	   || !opt_for_fn (e->caller->decl, optimize))
-	 return true;
-       if (!can_inline_edge_p (e, true))
-         return true;
-       if (e->recursive_p ())
-	 return true;
-       if (!can_inline_edge_by_limits_p (e, true))
-         return true;
-       if (!(*(bool *)has_hot_call) && e->maybe_hot_p ())
-	 *(bool *)has_hot_call = true;
-     }
+  for (e = node->callers; e; e = e->next_caller)
+    {
+      if (!opt_for_fn (e->caller->decl, flag_inline_functions_called_once)
+	  || !opt_for_fn (e->caller->decl, optimize))
+	return true;
+      if (!can_inline_edge_p (e, true))
+	return true;
+      if (e->recursive_p ())
+	return true;
+      if (!can_inline_edge_by_limits_p (e, true))
+	return true;
+      /* Inlining large functions to large loop depth is often harmful because
+	 of register pressure it implies.  */
+      if ((int)ipa_call_summaries->get (e)->loop_depth
+	  > param_inline_functions_called_once_loop_depth)
+	return false;
+      /* Do not produce gigantic functions.  */
+      if (estimate_size_after_inlining (e->caller->inlined_to ?
+					e->caller->inlined_to : e->caller, e)
+	  > param_inline_functions_called_once_insns)
+	return false;
+      if (!(*(bool *)has_hot_call) && e->maybe_hot_p ())
+	*(bool *)has_hot_call = true;
+    }
   return false;
 }
 
@@ -1327,9 +1337,12 @@ edge_badness (struct cgraph_edge *edge, bool dump)
 		   " %i (compensated)\n",
 		   badness.to_double (),
 		   freq.to_double (),
-		   edge->count.ipa ().initialized_p () ? edge->count.ipa ().to_gcov_type () : -1,
-		   caller->count.ipa ().initialized_p () ? caller->count.ipa ().to_gcov_type () : -1,
-		   inlining_speedup (edge, freq, unspec_edge_time, edge_time).to_double (),
+		   edge->count.ipa ().initialized_p ()
+		   ? edge->count.ipa ().to_gcov_type () : -1,
+		   caller->count.ipa ().initialized_p ()
+		   ? caller->count.ipa ().to_gcov_type () : -1,
+		   inlining_speedup (edge, freq, unspec_edge_time,
+				     edge_time).to_double (),
 		   estimate_growth (callee),
 		   callee_info->growth, overall_growth);
 	}
diff --git a/gcc/params.opt b/gcc/params.opt
index e725c99e5e4..47979f36cc8 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -545,6 +545,14 @@ The maximum expansion factor when copying basic blocks.
 Common Joined UInteger Var(param_max_hoist_depth) Init(30) Param Optimization
 Maximum depth of search in the dominator tree for expressions to hoist.
 
+-param=max-inline-functions-called-once-loop-depth=
+Common Joined UInteger Var(param_inline_functions_called_once_loop_depth) Init(6) Optimization Param
+Maximum loop depth of a call which is considered for inlining functions called once
+
+-param=max-inline-functions-called-once-insns=
+Common Joined UInteger Var(param_inline_functions_called_once_insns) Init(500) Optimization Param
+Maximum combinaed size of caller and callee wich is inlined if callee is called once.
+
 -param=max-inline-insns-auto=
 Common Joined UInteger Var(param_max_inline_insns_auto) Init(15) Optimization Param
 The maximum number of instructions when automatically inlining.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-03 12:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 12:20 [gcc(refs/users/hubicka/heads/honza-gcc-benchmark-branch-v2)] Reduce inlining functions called once Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).