Commit af33044f by Richard Henderson Committed by Richard Henderson

re PR tree-optimization/31169 (Bootstrap comparison error at revision 122821)

        PR tree-optimization/31169 
        * tree-vrp.c (extract_range_from_binary_expr) <RSHIFT_EXPR>: Drop
        to varying if the range is outside [0,  prec-1].

From-SVN: r123405
parent a616b1da
2007-04-01 Richard Henderson <rth@redhat.com>
PR tree-optimization/31169
* tree-vrp.c (extract_range_from_binary_expr) <RSHIFT_EXPR>: Drop
to varying if the range is outside [0, prec-1].
2007-04-01 Richard Sandiford <richard@codesourcery.com> 2007-04-01 Richard Sandiford <richard@codesourcery.com>
PR target/31388 PR target/31388
......
...@@ -1813,16 +1813,24 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr) ...@@ -1813,16 +1813,24 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr)
return; return;
} }
/* If we have a RSHIFT_EXPR with a possibly negative shift /* If we have a RSHIFT_EXPR with any shift values outside [0..prec-1],
count or an anti-range shift count drop to VR_VARYING. then drop to VR_VARYING. Outside of this range we get undefined
We currently cannot handle the overflow cases correctly. */ behaviour from the shift operation. We cannot even trust
if (code == RSHIFT_EXPR SHIFT_COUNT_TRUNCATED at this stage, because that applies to rtl
&& (vr1.type == VR_ANTI_RANGE shifts, and the operation at the tree level may be widened. */
|| !vrp_expr_computes_nonnegative (op1, &sop))) if (code == RSHIFT_EXPR)
{
if (vr1.type == VR_ANTI_RANGE
|| !vrp_expr_computes_nonnegative (op1, &sop)
|| (operand_less_p
(build_int_cst (TREE_TYPE (vr1.max),
TYPE_PRECISION (TREE_TYPE (expr)) - 1),
vr1.max) != 0))
{ {
set_value_range_to_varying (vr); set_value_range_to_varying (vr);
return; return;
} }
}
/* Multiplications and divisions are a bit tricky to handle, /* Multiplications and divisions are a bit tricky to handle,
depending on the mix of signs we have in the two ranges, we depending on the mix of signs we have in the two ranges, we
...@@ -1838,8 +1846,7 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr) ...@@ -1838,8 +1846,7 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr)
the new range. */ the new range. */
/* Divisions by zero result in a VARYING value. */ /* Divisions by zero result in a VARYING value. */
if ((code != MULT_EXPR else if (code != MULT_EXPR
&& code != RSHIFT_EXPR)
&& (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1))) && (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1)))
{ {
set_value_range_to_varying (vr); set_value_range_to_varying (vr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment