diff options
author | Jan Hubicka <jh@suse.cz> | 2012-10-28 13:00:32 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2012-10-28 12:00:32 +0000 |
commit | bf3f651054fdf0fdd672ffe344b0886e74f20098 (patch) | |
tree | bb44264423c65bd2e325dd7398d14e341c3b013a /gcc | |
parent | 5d517141037264e94ae503a0f883f074aad2b8fb (diff) | |
download | gcc-bf3f651054fdf0fdd672ffe344b0886e74f20098.zip gcc-bf3f651054fdf0fdd672ffe344b0886e74f20098.tar.gz gcc-bf3f651054fdf0fdd672ffe344b0886e74f20098.tar.bz2 |
inlinehint-3.c: New testcase.
* gcc.dg/ipa/inlinehint-3.c: New testcase.
* ipa-inline.c (edge_badness): Fix overflow.
(inline_small_functions): Initialize SCCs correctly.
(do_estimate_edge_time, do_estimate_edge_hints): Skip self
recursive functions in SCC hints.
From-SVN: r192891
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ipa-inline-analysis.c | 9 | ||||
-rw-r--r-- | gcc/ipa-inline.c | 19 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/inlinehint-3.c | 37 |
4 files changed, 67 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ed5d44..1e30bc1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2012-10-28 Jan Hubicka <jh@suse.cz> + + * gcc.dg/ipa/inlinehint-3.c: New testcase. + * ipa-inline.c (edge_badness): Fix overflow. + (inline_small_functions): Initialize SCCs correctly. + (do_estimate_edge_time, do_estimate_edge_hints): Skip self + recursive functions in SCC hints. + 2012-10-28 Steven Bosscher <steven@gcc.gnu.org> PR rtl-optimization/38711 diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 8dd9c69..3b56e7a 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -1375,6 +1375,9 @@ dump_inline_summary (FILE * f, struct cgraph_node *node) (int) s->estimated_self_stack_size); fprintf (f, " global stack: %i\n", (int) s->estimated_stack_size); + if (s->scc_no) + fprintf (f, " In SCC: %i\n", + (int) s->scc_no); for (i = 0; VEC_iterate (size_time_entry, s->entry, i, e); i++) @@ -3348,7 +3351,8 @@ do_estimate_edge_time (struct cgraph_edge *edge) VEC_index (edge_growth_cache_entry, edge_growth_cache, edge->uid).size = size + (size >= 0); if (inline_summary (to)->scc_no - && inline_summary (to)->scc_no == inline_summary (callee)->scc_no) + && inline_summary (to)->scc_no == inline_summary (callee)->scc_no + && !cgraph_edge_recursive_p (edge)) hints |= INLINE_HINT_same_scc; VEC_index (edge_growth_cache_entry, edge_growth_cache, edge->uid).hints = hints + 1; @@ -3439,7 +3443,8 @@ do_estimate_edge_hints (struct cgraph_edge *edge) VEC_free (tree, heap, known_binfos); VEC_free (ipa_agg_jump_function_p, heap, known_aggs); if (inline_summary (to)->scc_no - && inline_summary (to)->scc_no == inline_summary (callee)->scc_no) + && inline_summary (to)->scc_no == inline_summary (callee)->scc_no + && !cgraph_edge_recursive_p (edge)) hints |= INLINE_HINT_same_scc; return hints; } diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 39e450d..6d5b252 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -861,9 +861,9 @@ edge_badness (struct cgraph_edge *edge, bool dump) We might mix the valud into the fraction by taking into account relative growth of the unit, but for now just add the number into resulting fraction. */ - if (badness > INT_MAX / 4) + if (badness > INT_MAX / 8) { - badness = INT_MAX / 4; + badness = INT_MAX / 8; if (dump) fprintf (dump_file, "Badness overflow\n"); } @@ -1360,8 +1360,19 @@ inline_small_functions (void) if (!DECL_EXTERNAL (node->symbol.decl)) initial_size += info->size; - info->scc_no = (dfs && dfs->next_cycle && dfs->next_cycle != node - ? dfs->scc_no + 1 : 0); + if (dfs && dfs->next_cycle) + { + struct cgraph_node *n2; + int id = dfs->scc_no + 1; + for (n2 = node; n2; + n2 = ((struct ipa_dfs_info *) node->symbol.aux)->next_cycle) + { + struct inline_summary *info2 = inline_summary (n2); + if (info2->scc_no) + break; + info2->scc_no = id; + } + } } for (edge = node->callers; edge; edge = edge->next_caller) diff --git a/gcc/testsuite/gcc.dg/ipa/inlinehint-3.c b/gcc/testsuite/gcc.dg/ipa/inlinehint-3.c new file mode 100644 index 0000000..110ae44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/inlinehint-3.c @@ -0,0 +1,37 @@ +/* { dg-options "-O3 -c -fdump-ipa-inline-details -fno-early-inlining -fno-ipa-cp" } */ +void abort (void); +int sum; +int a[10]; +int +scc_next (int c) +{ + int i; + for (i=0;i<c;i++) + a[i]=c; + scc_entry (c); +} +int +scc_entry (int c) +{ + int i; + for (i=0;i<c;i++) + sum+=a[i]; + if (c--) + scc_next (c); + return sum; +} +main() +{ + int sum; + int i; + for (i=0;i<10;i++) + scc_entry (i); + if (sum < 0) + abort (); + return 0; +} +/* { dg-final { scan-ipa-dump "in_scc" "inline" } } */ +/* { dg-final { scan-ipa-dump "same_scc" "inline" } } */ +/* Main is not in scc, the two functions are. */ +/* { dg-final { scan-ipa-dump-times "In SCC" 2 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ |