From b7c27d5169bfb98ea4d73c52c4e17961cb9ab160 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Wed, 24 Jan 2007 23:45:00 +0100 Subject: [PATCH] ipa-inline.c (initial_insns, max_insns): Delete. * ipa-inline.c (initial_insns, max_insns): Delete. (compute_max_insns): New function. (cgraph_decide_inlining_of_small_function): Use it; take minimal amount of insns as base for code growth. (cgraph_decide_inlining): Make initial_insns local; do not compute max_insns. * params.def (PARAM_INLINE_UNIT_GROWTH): Set to 60. * doc/invoke.texi (inline-unit-growth): Update docs. From-SVN: r121144 --- gcc/ChangeLog | 11 +++++++++++ gcc/doc/invoke.texi | 2 +- gcc/ipa-inline.c | 38 +++++++++++++++++++++++++++----------- gcc/params.def | 2 +- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a3ff07b4f02..6a8e41e36d0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2007-01-24 Jan Hubicka + + * ipa-inline.c (initial_insns, max_insns): Delete. + (compute_max_insns): New function. + (cgraph_decide_inlining_of_small_function): Use it; take minimal amount + of insns as base for code growth. + (cgraph_decide_inlining): Make initial_insns local; do not compute + max_insns. + * params.def (PARAM_INLINE_UNIT_GROWTH): Set to 60. + * doc/invoke.texi (inline-unit-growth): Update docs. + 2007-01-24 Jakub Jelinek * config/i386/i386.h (x86_cmpxchg16b): Remove const. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index ab7342d36ac..4cd0a43ce48 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -6096,7 +6096,7 @@ before applying @option{--param inline-unit-growth}. The default is 10000 @item inline-unit-growth Specifies maximal overall growth of the compilation unit caused by inlining. This parameter is ignored when @option{-funit-at-a-time} is not used. -The default value is 50 which limits unit growth to 1.5 times the original +The default value is 60 which limits unit growth to 1.6 times the original size. @item large-stack-frame diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 646b72e7c42..803bc9d70d0 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -169,9 +169,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *, enum inlining_mode, /* Statistics we collect about inlining algorithm. */ static int ncalls_inlined; static int nfunctions_inlined; -static int initial_insns; static int overall_insns; -static int max_insns; static gcov_type max_count; /* Estimate size of the function after inlining WHAT into TO. */ @@ -753,6 +751,19 @@ cgraph_set_inline_failed (struct cgraph_node *node, const char *reason) e->inline_failed = reason; } +/* Given whole compilation unit esitmate of INSNS, compute how large we can + allow the unit to grow. */ +static int +compute_max_insns (int insns) +{ + int max_insns = insns; + if (max_insns < PARAM_VALUE (PARAM_LARGE_UNIT_INSNS)) + max_insns = PARAM_VALUE (PARAM_LARGE_UNIT_INSNS); + + return max_insns = ((HOST_WIDEST_INT) max_insns + * (100 + PARAM_VALUE (PARAM_INLINE_UNIT_GROWTH)) / 100); +} + /* We use greedy algorithm for inlining of small functions: All inline candidates are put into prioritized heap based on estimated growth of the overall number of instructions and then update the estimates. @@ -768,6 +779,7 @@ cgraph_decide_inlining_of_small_functions (void) const char *failed_reason; fibheap_t heap = fibheap_new (); bitmap updated_nodes = BITMAP_ALLOC (NULL); + int min_insns, max_insns; if (dump_file) fprintf (dump_file, "\nDeciding on smaller functions:\n"); @@ -796,6 +808,10 @@ cgraph_decide_inlining_of_small_functions (void) edge->aux = fibheap_insert (heap, cgraph_edge_badness (edge), edge); } } + + max_insns = compute_max_insns (overall_insns); + min_insns = overall_insns; + while (overall_insns <= max_insns && (edge = fibheap_extract_min (heap))) { int old_insns = overall_insns; @@ -923,6 +939,14 @@ cgraph_decide_inlining_of_small_functions (void) edge->caller->global.insns, overall_insns - old_insns); } + if (min_insns > overall_insns) + { + min_insns = overall_insns; + max_insns = compute_max_insns (min_insns); + + if (dump_file) + fprintf (dump_file, "New minimal insns reached: %i\n", min_insns); + } } while ((edge = fibheap_extract_min (heap)) != NULL) { @@ -949,6 +973,7 @@ cgraph_decide_inlining (void) XCNEWVEC (struct cgraph_node *, cgraph_n_nodes); int old_insns = 0; int i; + int initial_insns; max_count = 0; for (node = cgraph_nodes; node; node = node->next) @@ -965,13 +990,6 @@ cgraph_decide_inlining (void) overall_insns = initial_insns; gcc_assert (!max_count || (profile_info && flag_branch_probabilities)); - max_insns = overall_insns; - if (max_insns < PARAM_VALUE (PARAM_LARGE_UNIT_INSNS)) - max_insns = PARAM_VALUE (PARAM_LARGE_UNIT_INSNS); - - max_insns = ((HOST_WIDEST_INT) max_insns - * (100 + PARAM_VALUE (PARAM_INLINE_UNIT_GROWTH)) / 100); - nnodes = cgraph_postorder (order); if (dump_file) @@ -996,12 +1014,10 @@ cgraph_decide_inlining (void) /* Handle nodes to be flattened, but don't update overall unit size. */ if (lookup_attribute ("flatten", DECL_ATTRIBUTES (node->decl)) != NULL) { - int old_overall_insns = overall_insns; if (dump_file) fprintf (dump_file, "Flattening %s\n", cgraph_node_name (node)); cgraph_decide_inlining_incrementally (node, INLINE_ALL, 0); - overall_insns = old_overall_insns; } if (!node->local.disregard_inline_limits) diff --git a/gcc/params.def b/gcc/params.def index 6528361e6e9..c4f7229afdf 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -199,7 +199,7 @@ DEFPARAM(PARAM_LARGE_UNIT_INSNS, DEFPARAM(PARAM_INLINE_UNIT_GROWTH, "inline-unit-growth", "how much can given compilation unit grow because of the inlining (in percent)", - 50, 0, 0) + 60, 0, 0) DEFPARAM(PARAM_INLINE_CALL_COST, "inline-call-cost", "expense of call operation relative to ordinary arithmetic operations", -- 2.30.2