diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-10-16 09:50:44 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-10-16 09:50:44 +0000 |
commit | 96eb7d7a642085f651e9940f0ee75568d7c4441d (patch) | |
tree | f7eca938631203946dc47f7d9408210613dc0571 /gcc/tree-vrp.c | |
parent | 4307a485c39fd1c317d6cead2707a903052c4753 (diff) |
Deal with incoming POLY_INT_CST ranges (PR92033)
This patch makes value_range_base::set convert POLY_INT_CST bounds
into the worst-case INTEGER_CST bounds. The main case in which this
gives useful ranges is a lower bound of A + B * X becoming A when B >= 0.
E.g.:
[32 + 16X, 100] -> [32, 100]
[32 + 16X, 32 + 16X] -> [32, MAX]
But the same thing can be useful for the upper bound with negative
X coefficients.
2019-10-16 Richard Sandiford <richard.sandiford@arm.com>
gcc/
PR middle-end/92033
* poly-int.h (constant_lower_bound_with_limit): New function.
(constant_upper_bound_with_limit): Likewise.
* doc/poly-int.texi: Document them.
* tree-vrp.c (value_range_base::set): Convert POLY_INT_CST bounds
into the worst-case INTEGER_CST bounds.
From-SVN: r277056
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index cffa0508340..21910b36518 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -727,6 +727,24 @@ value_range_base::set (enum value_range_kind kind, tree min, tree max) return; } + /* Convert POLY_INT_CST bounds into worst-case INTEGER_CST bounds. */ + if (POLY_INT_CST_P (min)) + { + tree type_min = vrp_val_min (TREE_TYPE (min), true); + widest_int lb + = constant_lower_bound_with_limit (wi::to_poly_widest (min), + wi::to_widest (type_min)); + min = wide_int_to_tree (TREE_TYPE (min), lb); + } + if (POLY_INT_CST_P (max)) + { + tree type_max = vrp_val_max (TREE_TYPE (max), true); + widest_int ub + = constant_upper_bound_with_limit (wi::to_poly_widest (max), + wi::to_widest (type_max)); + max = wide_int_to_tree (TREE_TYPE (max), ub); + } + /* Nothing to canonicalize for symbolic ranges. */ if (TREE_CODE (min) != INTEGER_CST || TREE_CODE (max) != INTEGER_CST) |