http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49234



Aldy Hernandez <aldyh at gcc dot gnu.org> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |dnovillo at gcc dot

                   |                            |gnu.org, rguenth at gcc dot

                   |                            |gnu.org



--- Comment #8 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2013-02-28 
16:00:26 UTC ---

As Jakub explained in comment 3, this is a problem in the VRP code.



To avoid bouncing from max to max (or slowly increasing to +INF), we

immediately go to +INF(OVF), even if we have correct ranges.



One alternative that I show in the attached patch (comment 7: proof of concept

hack, untested), is to keep track of how many times we are iterating through an

SSA.  If we go past an arbitrary number (say 10), we can then go to +INF.



So basically, keep track of a few states, but if it starts getting ridiculous

step it up to INF.  Similarly for the cmp_min code.  The relevant part of my

patch is shown below.



Does this seem like an approach worth exploring (this silences the warning), or

does anyone have a better suggestion?



-      /* Similarly, if the new maximum is smaller or larger than

-     the previous one, go all the way to +INF.  */

-      if (cmp_max < 0 || cmp_max > 0)

+      /* Adjust to a new maximum if it has changed.  For the first few

+     iterations, adjust the maximum accordingly.  However, if

+     we're iterating too much, go all the way to +INF to avoid

+     either bouncing around or iterating millions of times to

+     reach +INF.  */

+      if ((cmp_max < 0 || cmp_max > 0))

     {

-      if (!needs_overflow_infinity (TREE_TYPE (vr_result.max))

-          || !vrp_var_may_overflow (lhs, phi))

-        vr_result.max = TYPE_MAX_VALUE (TREE_TYPE (vr_result.max));

-      else if (supports_overflow_infinity (TREE_TYPE (vr_result.max)))

-        vr_result.max =

-        positive_overflow_infinity (TREE_TYPE (vr_result.max));

+      lhs_vr->visited++;

+      if (lhs_vr->visited < 10) // Handle the first 10 iterations.

+        vr_result.max = lhs_vr->max;

+      else

+        {

+          if (!needs_overflow_infinity (TREE_TYPE (vr_result.max))

+          || !vrp_var_may_overflow (lhs, phi))

+        vr_result.max = TYPE_MAX_VALUE (TREE_TYPE (vr_result.max));

+          else if (supports_overflow_infinity (TREE_TYPE (vr_result.max)))

+        vr_result.max =

+          positive_overflow_infinity (TREE_TYPE (vr_result.max));

+        }

     }

Reply via email to