From f5b25e15165adde1356af42e9066ab75c5b37a19 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Thu, 16 Jan 2020 23:55:44 +0100 Subject: Make profile estimation more precise While analyzing code size regression in SPEC2k GCC binary I noticed that we perform some inline decisions because we think that number of executions are very high. In particular there was inline decision inlining gen_rtx_fmt_ee to find_reloads believing that it is called 4 billion times. This turned out to be cummulation of roundoff errors in propagate_freq which was bit mechanically updated from original sreals to C++ sreals and later to new probabilities. This led us to estimate that a loopback edge is reached with probability 2.3 which was capped to 1-1/10000 and since this happened in nested loop it quickly escalated to large values. Originally capping to REG_BR_PROB_BASE avoided such problems but now we have much higher range. This patch avoids going from probabilites to REG_BR_PROB_BASE so precision is kept. In addition it makes the propagation to not estimate more than param-max-predicted-loop-iterations. The first change makes the cap to not be triggered on the gcc build, but it is still better to be safe than sorry. * ipa-fnsummary.c (estimate_calls_size_and_time): Fix formating of dump. * params.opt: (max-predicted-iterations): Set bounds. * predict.c (real_almost_one, real_br_prob_base, real_inv_br_prob_base, real_one_half, real_bb_freq_max): Remove. (propagate_freq): Add max_cyclic_prob parameter; cap cyclic probabilities; do not truncate to reg_br_prob_bases. (estimate_loops_at_level): Pass max_cyclic_prob. (estimate_loops): Compute max_cyclic_prob. (estimate_bb_frequencies): Do not initialize real_*; update calculation of back edge prob. * profile-count.c (profile_probability::to_sreal): New. * profile-count.h (class sreal): Move up in file. (profile_probability::to_sreal): Declare. --- gcc/profile-count.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/profile-count.h') diff --git a/gcc/profile-count.h b/gcc/profile-count.h index 987d3ce..09217a8 100644 --- a/gcc/profile-count.h +++ b/gcc/profile-count.h @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see struct function; struct profile_count; +class sreal; /* Quality of the profile count. Because gengtype does not support enums inside of classes, this is in global namespace. */ @@ -614,6 +615,8 @@ public: profile_probability other, profile_count count2) const; + /* Return probability as sreal. */ + sreal to_sreal () const; /* LTO streaming support. */ static profile_probability stream_in (class lto_input_block *); void stream_out (struct output_block *); @@ -674,8 +677,6 @@ public: */ -class sreal; - struct GTY(()) profile_count { public: -- cgit v1.1