aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2019-11-19 19:56:26 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2019-11-19 18:56:26 +0000
commitea8dd3b6cea2a4d4dab7e2997b88a170f8093ce6 (patch)
tree5067144beb28608066ee17d63498e10647744fdb /gcc
parent4aa5fd8aca1140adf0917dc53397efddc7fd4c11 (diff)
downloadgcc-ea8dd3b6cea2a4d4dab7e2997b88a170f8093ce6.zip
gcc-ea8dd3b6cea2a4d4dab7e2997b88a170f8093ce6.tar.gz
gcc-ea8dd3b6cea2a4d4dab7e2997b88a170f8093ce6.tar.bz2
Avoid redundant computations in edge_badness.
* ipa-inline.c (inlining_speedup): New function. (edge_badness): Use it. From-SVN: r278459
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/ipa-inline.c37
2 files changed, 35 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3516235..710f8da 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-18 Jan Hubicka <jh@suse.cz>
+
+ * ipa-inline.c (inlining_speedup): New function.
+ (edge_badness): Use it.
+
2019-11-19 Zoran Jovanovic <zoran.jovanovic@mips.com>
Dragan Mladjenovic <dmladjenovic@wavecomp.com>
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 1f77ba2..becea8a 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -768,6 +768,33 @@ compute_inlined_call_time (struct cgraph_edge *edge,
return time;
}
+/* Determine time saved by inlininig EDGE of frequency FREQ
+ where callee's runtime w/o inlineing is UNINLINED_TYPE
+ and with inlined is INLINED_TYPE. */
+
+inline sreal
+inlining_speedup (struct cgraph_edge *edge,
+ sreal freq,
+ sreal uninlined_time,
+ sreal inlined_time)
+{
+ sreal speedup = uninlined_time - inlined_time;
+ /* Handling of call_time should match one in ipa-inline-fnsummary.c
+ (estimate_edge_size_and_time). */
+ sreal call_time = ipa_call_summaries->get (edge)->call_stmt_time;
+
+ if (freq > 0)
+ {
+ speedup = (speedup + call_time);
+ if (freq != 1)
+ speedup = speedup * freq;
+ }
+ else if (freq == 0)
+ speedup = speedup >> 11;
+ gcc_checking_assert (speedup >= 0);
+ return speedup;
+}
+
/* Return true if the speedup for inlining E is bigger than
PARAM_MAX_INLINE_MIN_SPEEDUP. */
@@ -1149,10 +1176,8 @@ edge_badness (struct cgraph_edge *edge, bool dump)
sreal numerator, denominator;
int overall_growth;
sreal freq = edge->sreal_frequency ();
- sreal inlined_time = compute_inlined_call_time (edge, edge_time, freq);
- numerator = (compute_uninlined_call_time (edge, unspec_edge_time, freq)
- - inlined_time);
+ numerator = inlining_speedup (edge, freq, unspec_edge_time, edge_time);
if (numerator <= 0)
numerator = ((sreal) 1 >> 8);
if (caller->count.ipa ().nonzero_p ())
@@ -1235,16 +1260,14 @@ edge_badness (struct cgraph_edge *edge, bool dump)
fprintf (dump_file,
" %f: guessed profile. frequency %f, count %" PRId64
" caller count %" PRId64
- " time w/o inlining %f, time with inlining %f"
+ " time saved %f"
" overall growth %i (current) %i (original)"
" %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,
- compute_uninlined_call_time (edge,
- unspec_edge_time, freq).to_double (),
- inlined_time.to_double (),
+ inlining_speedup (edge, freq, unspec_edge_time, edge_time).to_double (),
estimate_growth (callee),
callee_info->growth, overall_growth);
}