------- Comment #6 from ian at airs dot com  2007-04-11 07:15 -------
When we pick a new range to avoid an infinite iteration, we have to pick an
overflow range.  This is what catches overflows like
    for (i = 1; i > 0; ++i) ++bits;

I've experimented with only doing this in a loop, but it didn't work reliably.

Note that we don't throw away all infinities here, we just throw away
[-INF,+INF].  This is code from before the overflow checks were added.

The suggestion of all_but_one_const sounds reasonable to me.  What do you think
of this patch?

Index: tree-vrp.c
===================================================================
--- tree-vrp.c  (revision 123521)
+++ tree-vrp.c  (working copy)
@@ -5059,7 +5059,7 @@ vrp_visit_phi_node (tree phi)
   tree lhs = PHI_RESULT (phi);
   value_range_t *lhs_vr = get_value_range (lhs);
   value_range_t vr_result = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
-  bool all_const = true;
+  int variable_count;

   copy_value_range (&vr_result, lhs_vr);

@@ -5069,6 +5069,7 @@ vrp_visit_phi_node (tree phi)
       print_generic_expr (dump_file, phi, dump_flags);
     }

+  variable_count = 0;
   for (i = 0; i < PHI_NUM_ARGS (phi); i++)
     {
       edge e = PHI_ARG_EDGE (phi, i);
@@ -5089,7 +5090,7 @@ vrp_visit_phi_node (tree phi)
          if (TREE_CODE (arg) == SSA_NAME)
            {
              vr_arg = *(get_value_range (arg));
-             all_const = false;
+             ++variable_count;
            }
          else
            {
@@ -5122,7 +5123,7 @@ vrp_visit_phi_node (tree phi)
      when the new value is slightly bigger or smaller than the
      previous one.  */
   if (lhs_vr->type == VR_RANGE && vr_result.type == VR_RANGE
-      && !all_const)
+      && variable_count > 1)
     {
       if (!POINTER_TYPE_P (TREE_TYPE (lhs)))
        {


-- 


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

Reply via email to