diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-09-25 14:46:54 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2012-09-25 14:46:54 +0200 |
commit | 5717e1f6488ce9b376e1f4a45787687538ec2993 (patch) | |
tree | b63a6329eba3c58e20da4ed4266ce308aa4285c3 /gcc/tree-vrp.c | |
parent | dadbefd3596a06d06f539e4c0048326a26ac3c75 (diff) | |
download | gcc-5717e1f6488ce9b376e1f4a45787687538ec2993.zip gcc-5717e1f6488ce9b376e1f4a45787687538ec2993.tar.gz gcc-5717e1f6488ce9b376e1f4a45787687538ec2993.tar.bz2 |
re PR tree-optimization/54676 (ICE: in set_value_range, at tree-vrp.c:433)
PR tree-optimization/54676
* tree-vrp.c (set_and_canonicalize_value_range): Handle
one bit precision properly.
* gcc.dg/pr54676.c: New test.
From-SVN: r191703
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index a84c4b9..b728ddd 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -501,8 +501,19 @@ set_and_canonicalize_value_range (value_range_t *vr, enum value_range_type t, to adjust them. */ if (tree_int_cst_lt (max, min)) { - tree one = build_int_cst (TREE_TYPE (min), 1); - tree tmp = int_const_binop (PLUS_EXPR, max, one); + tree one, tmp; + + /* For one bit precision if max < min, then the swapped + range covers all values, so for VR_RANGE it is varying and + for VR_ANTI_RANGE empty range, so drop to varying as well. */ + if (TYPE_PRECISION (TREE_TYPE (min)) == 1) + { + set_value_range_to_varying (vr); + return; + } + + one = build_int_cst (TREE_TYPE (min), 1); + tmp = int_const_binop (PLUS_EXPR, max, one); max = int_const_binop (MINUS_EXPR, min, one); min = tmp; @@ -531,6 +542,24 @@ set_and_canonicalize_value_range (value_range_t *vr, enum value_range_type t, set_value_range_to_varying (vr); return; } + else if (TYPE_PRECISION (TREE_TYPE (min)) == 1 + && !TYPE_UNSIGNED (TREE_TYPE (min)) + && (is_min || is_max)) + { + /* For signed 1-bit precision, one is not in-range and + thus adding/subtracting it would result in overflows. */ + if (operand_equal_p (min, max, 0)) + { + min = max = is_min ? vrp_val_max (TREE_TYPE (min)) + : vrp_val_min (TREE_TYPE (min)); + t = VR_RANGE; + } + else + { + set_value_range_to_varying (vr); + return; + } + } else if (is_min /* As a special exception preserve non-null ranges. */ && !(TYPE_UNSIGNED (TREE_TYPE (min)) |