------- Comment #8 from pinskia at gcc dot gnu dot org  2006-05-05 09:13 -------
Here is a quick prototype addition for VRP, it does not handle the generic case
only [0, 1] | 1:
Index: tree-vrp.c
===================================================================
--- tree-vrp.c  (revision 113452)
+++ tree-vrp.c  (working copy)
@@ -1276,6 +1276,7 @@ extract_range_from_binary_expr (value_ra
       && code != MIN_EXPR
       && code != MAX_EXPR
       && code != BIT_AND_EXPR
+      && code != BIT_IOR_EXPR
       && code != TRUTH_ANDIF_EXPR
       && code != TRUTH_ORIF_EXPR
       && code != TRUTH_AND_EXPR
@@ -1319,6 +1320,7 @@ extract_range_from_binary_expr (value_ra
      the operands is VR_VARYING or symbolic range.  TODO, we may be
      able to derive anti-ranges in some cases.  */
   if (code != BIT_AND_EXPR
+      && code != BIT_IOR_EXPR
       && code != TRUTH_AND_EXPR
       && code != TRUTH_OR_EXPR
       && (vr0.type == VR_VARYING
@@ -1568,6 +1570,27 @@ extract_range_from_binary_expr (value_ra
          return;
        }
     }
+  else if (code == BIT_IOR_EXPR)
+    {
+      /* FIXME.  Handle only: [0, 1] | [1, 1], this should be expanded to
handle:
+         [ a, b ] | [b | b]. */
+      if (vr1.type == VR_RANGE
+         && vr1.min == vr1.max
+         && integer_onep (vr1.max)
+         && vr0.type == VR_RANGE
+         && integer_zerop (vr0.min)
+         && integer_onep (vr0.max))
+       {
+         type = VR_RANGE;
+         min = build_int_cst (TREE_TYPE (expr), 1);
+         max = build_int_cst (TREE_TYPE (expr), 1);
+       }
+      else
+       {
+         set_value_range_to_varying (vr);
+         return;
+       }
+    }
   else
     gcc_unreachable ();



-- 


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

Reply via email to