diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c index 4c474cdfb4d..d78b6f8423c 100644 --- a/gcc/gimple-ssa-evrp-analyze.c +++ b/gcc/gimple-ssa-evrp-analyze.c @@ -109,7 +109,7 @@ evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range_equiv *vr) /* Set the SSA with the value range. */ if (INTEGRAL_TYPE_P (TREE_TYPE (lhs))) { - if (vr->constant_p ()) + if (!vr->varying_p () && vr->constant_p ()) set_range_info (lhs, vr->kind (), wi::to_wide (vr->min ()), wi::to_wide (vr->max ())); diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 62b90079a03..d968ef288ff 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4059,7 +4059,7 @@ vrp_prop::finalize () continue; const value_range_equiv *vr = m_vr_values->get_value_range (name); - if (!name || !vr->constant_p ()) + if (!name || vr->varying_p () || !vr->constant_p ()) continue; if (POINTER_TYPE_P (TREE_TYPE (name)) @@ -4679,7 +4679,7 @@ determine_value_range (tree expr, wide_int *min, wide_int *max) { value_range vr; determine_value_range_1 (&vr, expr); - if (vr.constant_p ()) + if (!vr.varying_p () && vr.constant_p ()) { *min = wi::to_wide (vr.min ()); *max = wi::to_wide (vr.max ()); diff --git a/gcc/value-range.cc b/gcc/value-range.cc index d46662397e7..f5ef4808530 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -534,22 +534,17 @@ irange::equal_p (const irange &other) const bool irange::symbolic_p () const { - return (!varying_p () - && !undefined_p () + return (m_num_ranges > 0 && (!is_gimple_min_invariant (min ()) || !is_gimple_min_invariant (max ()))); } -/* NOTE: This is not the inverse of symbolic_p because the range - could also be varying or undefined. Ideally they should be inverse - of each other, with varying only applying to symbolics. Varying of - constants would be represented as [-MIN, +MAX]. */ +/* Return TRUE if this is a constant range. */ bool irange::constant_p () const { - return (!varying_p () - && !undefined_p () + return (m_num_ranges > 0 && TREE_CODE (min ()) == INTEGER_CST && TREE_CODE (max ()) == INTEGER_CST); } diff --git a/gcc/vr-values.c b/gcc/vr-values.c index e117f66d1bd..08b237b2632 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -182,7 +182,7 @@ vr_values::range_of_expr (irange &r, tree expr, gimple *stmt) if (const value_range *vr = get_value_range (expr, stmt)) { - if (vr->undefined_p () || vr->varying_p () || vr->constant_p ()) + if (vr->undefined_p () || vr->constant_p ()) r = *vr; else {