diff options
author | Richard Henderson <rth@redhat.com> | 2007-04-01 11:17:38 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2007-04-01 11:17:38 -0700 |
commit | af33044f0598837e9dc2d584bb350ee2a5af156c (patch) | |
tree | 60c36006c1f1d38e5a8127cbbc7d68f8fab38359 /gcc/tree-vrp.c | |
parent | a616b1da79fa53234feb3367578720f0d6573cdc (diff) | |
download | gcc-af33044f0598837e9dc2d584bb350ee2a5af156c.zip gcc-af33044f0598837e9dc2d584bb350ee2a5af156c.tar.gz gcc-af33044f0598837e9dc2d584bb350ee2a5af156c.tar.bz2 |
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
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 3b7358d..dbb97de 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1813,15 +1813,23 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr) return; } - /* If we have a RSHIFT_EXPR with a possibly negative shift - count or an anti-range shift count drop to VR_VARYING. - We currently cannot handle the overflow cases correctly. */ - if (code == RSHIFT_EXPR - && (vr1.type == VR_ANTI_RANGE - || !vrp_expr_computes_nonnegative (op1, &sop))) + /* If we have a RSHIFT_EXPR with any shift values outside [0..prec-1], + then drop to VR_VARYING. Outside of this range we get undefined + behaviour from the shift operation. We cannot even trust + SHIFT_COUNT_TRUNCATED at this stage, because that applies to rtl + shifts, and the operation at the tree level may be widened. */ + if (code == RSHIFT_EXPR) { - set_value_range_to_varying (vr); - return; + 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); + return; + } } /* Multiplications and divisions are a bit tricky to handle, @@ -1838,9 +1846,8 @@ extract_range_from_binary_expr (value_range_t *vr, tree expr) the new range. */ /* Divisions by zero result in a VARYING value. */ - if ((code != MULT_EXPR - && code != RSHIFT_EXPR) - && (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1))) + else if (code != MULT_EXPR + && (vr0.type == VR_ANTI_RANGE || range_includes_zero_p (&vr1))) { set_value_range_to_varying (vr); return; |