diff options
author | Jan Hubicka <jh@suse.cz> | 2011-10-23 16:30:24 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2011-10-23 14:30:24 +0000 |
commit | d621a5fb6d9bd91e30e96ba9ee60ac8ec1350ee1 (patch) | |
tree | 01f1d3b41396eb45236943ca2cc45f29cc451e85 /gcc/ipa-inline.c | |
parent | fe646a69c7ef9614370dde7a5e4983b5095e6074 (diff) | |
download | gcc-d621a5fb6d9bd91e30e96ba9ee60ac8ec1350ee1.zip gcc-d621a5fb6d9bd91e30e96ba9ee60ac8ec1350ee1.tar.gz gcc-d621a5fb6d9bd91e30e96ba9ee60ac8ec1350ee1.tar.bz2 |
* ipa-inline.c (estimate_badness): Scale up and handle overflows.
From-SVN: r180336
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r-- | gcc/ipa-inline.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index f53f001..662c6b3 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -822,8 +822,10 @@ edge_badness (struct cgraph_edge *edge, bool dump) /* Result must be integer in range 0...INT_MAX. Set the base of fixed point calculation so we don't lose much of precision for small bandesses (those are interesting) yet we don't - overflow for growths that are still in interesting range. */ - badness = ((gcov_type)growth) * (1<<18); + overflow for growths that are still in interesting range. + + Fixed point arithmetic with point at 8th bit. */ + badness = ((gcov_type)growth) * (1<<(19+8)); badness = (badness + div / 2) / div; /* Overall growth of inlining all calls of function matters: we want to @@ -838,10 +840,14 @@ 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 / 2) + { + badness = INT_MAX / 2; + if (dump) + fprintf (dump_file, "Badness overflow\n"); + } growth_for_all = estimate_growth (callee); badness += growth_for_all; - if (badness > INT_MAX - 1) - badness = INT_MAX - 1; if (dump) { fprintf (dump_file, |