OSDN Git Service

* ipa-inline.c (estimate_badness): Scale up and handle overflows.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Oct 2011 14:30:24 +0000 (14:30 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 23 Oct 2011 14:30:24 +0000 (14:30 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180336 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa-inline.c

index 82105b4..2602f76 100644 (file)
@@ -1,3 +1,7 @@
+2011-10-23  Jan Hubicka  <jh@suse.cz>
+
+       * ipa-inline.c (estimate_badness): Scale up and handle overflows.
+
 2011-10-23  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/50788
 2011-10-23  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/50788
index f53f001..662c6b3 100644 (file)
@@ -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
       /* 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
       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.  */
         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;
       growth_for_all = estimate_growth (callee);
       badness += growth_for_all;
-      if (badness > INT_MAX - 1)
-       badness = INT_MAX - 1;
       if (dump)
        {
          fprintf (dump_file,
       if (dump)
        {
          fprintf (dump_file,