https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61725

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The alternative to teach it about signed ranges could be something like
(untested):

--- tree-vrp.c.jj    2014-06-24 09:38:12.000000000 +0200
+++ tree-vrp.c    2014-07-07 11:26:30.308749523 +0200
@@ -3536,15 +3536,18 @@ extract_range_basic (value_range_t *vr,
           /* If arg is non-zero, then ffs or popcount
          are non-zero.  */
           if (((vr0->type == VR_RANGE
-            && integer_nonzerop (vr0->min))
+            && range_includes_zero_p (vr0->min, vr0->max) == 0)
            || (vr0->type == VR_ANTI_RANGE
-               && integer_zerop (vr0->min)))
-          && !is_overflow_infinity (vr0->min))
+               && range_includes_zero_p (vr0->min, vr0->max) == 1))
+          && !is_overflow_infinity (vr0->min)
+          && !is_overflow_infinity (vr0->max))
         mini = 1;
           /* If some high bits are known to be zero,
          we can decrease the maximum.  */
           if (vr0->type == VR_RANGE
           && TREE_CODE (vr0->max) == INTEGER_CST
+          && !operand_less_p (vr0->min,
+                      build_zero_cst (TREE_TYPE (vr0->min)))
           && !is_overflow_infinity (vr0->max))
         maxi = tree_floor_log2 (vr0->max) + 1;
         }

Reply via email to