diff options
author | Aldy Hernandez <aldyh@gcc.gnu.org> | 2019-06-26 17:07:26 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2019-06-26 17:07:26 +0000 |
commit | 926261fd2c3f669b889f9a60042452c72c47f62b (patch) | |
tree | 5ed71300a6a634d503abdba5cdeee6ffab0b7f16 | |
parent | 2500cfac85e7d763dfc145197eecc2e2dac2bc43 (diff) | |
download | gcc-926261fd2c3f669b889f9a60042452c72c47f62b.zip gcc-926261fd2c3f669b889f9a60042452c72c47f62b.tar.gz gcc-926261fd2c3f669b889f9a60042452c72c47f62b.tar.bz2 |
Put TYPE_MIN/MAX_VALUE in varying and undefined ranges's min/max
instead of the type itself.
From-SVN: r272701
-rw-r--r-- | gcc/gimple-ssa-evrp-analyze.c | 8 | ||||
-rw-r--r-- | gcc/tree-ssanames.c | 8 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 103 | ||||
-rw-r--r-- | gcc/tree-vrp.h | 5 | ||||
-rw-r--r-- | gcc/vr-values.c | 9 |
5 files changed, 79 insertions, 54 deletions
diff --git a/gcc/gimple-ssa-evrp-analyze.c b/gcc/gimple-ssa-evrp-analyze.c index 6f82937..6f587b7 100644 --- a/gcc/gimple-ssa-evrp-analyze.c +++ b/gcc/gimple-ssa-evrp-analyze.c @@ -211,8 +211,7 @@ evrp_range_analyzer::record_ranges_from_incoming_edge (basic_block bb) getting first [64, +INF] and then ~[0, 0] from conditions like (s & 0x3cc0) == 0). */ value_range *old_vr = get_value_range (vrs[i].first); - value_range_base tem (old_vr->kind (), old_vr->min (), - old_vr->max ()); + value_range_base tem = *old_vr; tem.intersect (vrs[i].second); if (tem.equal_p (*old_vr)) continue; @@ -252,6 +251,11 @@ evrp_range_analyzer::record_ranges_from_phis (basic_block bb) if (virtual_operand_p (lhs)) continue; + /* Skips floats and other things we can't represent in a + range. */ + if (!irange::supports_type_p (TREE_TYPE (lhs))) + continue; + value_range vr_result; bool interesting = stmt_interesting_for_vrp (phi); if (!has_unvisited_preds && interesting) diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c index 1199f64..ace62f4 100644 --- a/gcc/tree-ssanames.c +++ b/gcc/tree-ssanames.c @@ -440,14 +440,16 @@ get_range_info (const_tree name, value_range_base &vr) wide_int wmin, wmax; enum value_range_kind kind = get_range_info (name, &wmin, &wmax); - if (kind == VR_VARYING || kind == VR_UNDEFINED) - min = max = TREE_TYPE (name); + if (kind == VR_VARYING) + vr.set_varying (TREE_TYPE (name)); + else if (kind == VR_UNDEFINED) + vr.set_undefined (TREE_TYPE (name)); else { min = wide_int_to_tree (TREE_TYPE (name), wmin); max = wide_int_to_tree (TREE_TYPE (name), wmax); + vr.set (kind, min, max); } - vr.set (kind, min, max); return kind; } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 5d5ef59..aeaa8fd 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -255,9 +255,6 @@ value_range_base::equal_p (const value_range_base &other) const if (undefined_p ()) return m_kind == other.m_kind; - if (varying_p ()) - return m_kind == other.m_kind && types_compatible_p (m_min, other.m_min); - return (m_kind == other.m_kind && vrp_operand_equal_p (m_min, other.m_min) && vrp_operand_equal_p (m_max, other.m_max)); @@ -303,7 +300,22 @@ void value_range_base::set_undefined (tree type) { m_kind = VR_UNDEFINED; - m_min = m_max = type; + if (type) + { + if (irange::supports_type_p (type)) + { + m_min = vrp_val_min (type, true); + m_max = vrp_val_max (type, true); + } + else + { + /* This is a temporary kludge for ipa-cp which is building + undefined/varying of floats. ?? */ + m_min = m_max = build1 (NOP_EXPR, type, type); + } + } + else + m_min = m_max = NULL; } void @@ -317,7 +329,17 @@ void value_range_base::set_varying (tree type) { m_kind = VR_VARYING; - m_min = m_max = type; + if (irange::supports_type_p (type)) + { + m_min = vrp_val_min (type, true); + m_max = vrp_val_max (type, true); + } + else + { + /* This is a temporary kludge for ipa-cp which is building + undefined/varying of floats. ?? */ + m_min = m_max = build1 (NOP_EXPR, type, type); + } } void @@ -401,11 +423,6 @@ value_range_base::singleton_p (tree *result) const tree value_range_base::type () const { - if (undefined_p () || varying_p ()) - { - gcc_assert (min () != NULL); - return min (); - } return TREE_TYPE (min ()); } @@ -487,6 +504,12 @@ value_range::dump (FILE *file) const } void +value_range::dump () const +{ + dump (stderr); +} + +void dump_value_range (FILE *file, const value_range *vr) { if (!vr) @@ -722,14 +745,15 @@ value_range_base::set (enum value_range_kind kind, tree min, tree max) { if (kind == VR_UNDEFINED) { - gcc_assert (!min || TYPE_P (min)); - set_undefined (min); + if (min) + set_undefined (TREE_TYPE (min)); + else + set_undefined (); return; } else if (kind == VR_VARYING) { - gcc_assert (TYPE_P (min)); - set_varying (min); + set_varying (TREE_TYPE (min)); return; } @@ -6460,12 +6484,12 @@ value_range_base::intersect_helper (const value_range_base *vr0, VR_RANGE can still be a VR_RANGE. Work on a temporary so we can fall back to vr0 when this turns things to varying. */ value_range_base tem; - if (vr0type == VR_UNDEFINED || vr0type == VR_VARYING) - { - vr0min = TREE_TYPE (vr0->min ()); - vr0max = TREE_TYPE (vr0->min ()); - } - tem.set (vr0type, vr0min, vr0max); + if (vr0type == VR_UNDEFINED) + tem.set_undefined (TREE_TYPE (vr0->min ())); + else if (vr0type == VR_VARYING) + tem.set_varying (TREE_TYPE (vr0->min ())); + else + tem.set (vr0type, vr0min, vr0max); /* If that failed, use the saved original VR0. */ if (tem.varying_p ()) return *vr0; @@ -6570,12 +6594,12 @@ value_range_base::union_helper (const value_range_base *vr0, /* Work on a temporary so we can still use vr0 when union returns varying. */ value_range_base tem; - if (vr0type == VR_UNDEFINED || vr0type == VR_VARYING) - { - vr0min = TREE_TYPE (vr0->min ()); - vr0max = TREE_TYPE (vr0->min ()); - } - tem.set (vr0type, vr0min, vr0max); + if (vr0type == VR_UNDEFINED) + tem.set_undefined (TREE_TYPE (vr0->min ())); + else if (vr0type == VR_VARYING) + tem.set_varying (TREE_TYPE (vr0->min ())); + else + tem.set (vr0type, vr0min, vr0max); /* Failed to find an efficient meet. Before giving up and setting the result to VARYING, see if we can at least derive a useful @@ -6655,6 +6679,8 @@ value_range::union_ (const value_range *other) } } +/* Normalize symbolics into constants. */ + value_range_base value_range_base::normalize_symbolics () const { @@ -6666,7 +6692,7 @@ value_range_base::normalize_symbolics () const // [SYM, SYM] -> VARYING if (min_symbolic && max_symbolic) - goto varying; + return value_range_base (ttype); if (kind () == VR_RANGE) { // [SYM, NUM] -> [-MIN, NUM] @@ -6684,7 +6710,7 @@ value_range_base::normalize_symbolics () const tree n = wide_int_to_tree (ttype, wi::to_wide (max ()) + 1); return value_range_base (VR_RANGE, n, vrp_val_max (ttype)); } - goto varying; + return value_range_base (ttype); } // ~[NUM, SYM] -> [-MIN, NUM - 1] if (!vrp_val_is_min (min ())) @@ -6692,10 +6718,7 @@ value_range_base::normalize_symbolics () const tree n = wide_int_to_tree (ttype, wi::to_wide (min ()) - 1); return value_range_base (VR_RANGE, vrp_val_min (ttype), n); } - varying: - value_range_base tmp; - tmp.set_varying (ttype); - return tmp; + return value_range_base (ttype); } unsigned @@ -6727,11 +6750,7 @@ value_range_base::lower_bound (unsigned pair) const gcc_assert (!undefined_p ()); gcc_assert (pair + 1 <= num_pairs ()); tree t = NULL; - if (varying_p ()) - t = vrp_val_min (type (), true); - else if (m_kind == VR_RANGE) - t = m_min; - else if (m_kind == VR_ANTI_RANGE) + if (m_kind == VR_ANTI_RANGE) { value_range_base vr0, vr1; gcc_assert (ranges_from_anti_range (this, &vr0, &vr1, true)); @@ -6742,6 +6761,8 @@ value_range_base::lower_bound (unsigned pair) const else gcc_unreachable (); } + else + t = m_min; return wi::to_wide (t); } @@ -6754,11 +6775,7 @@ value_range_base::upper_bound (unsigned pair) const gcc_assert (!undefined_p ()); gcc_assert (pair + 1 <= num_pairs ()); tree t = NULL; - if (varying_p ()) - t = vrp_val_max (type (), true); - else if (m_kind == VR_RANGE) - t = m_max; - else if (m_kind == VR_ANTI_RANGE) + if (m_kind == VR_ANTI_RANGE) { value_range_base vr0, vr1; gcc_assert (ranges_from_anti_range (this, &vr0, &vr1, true)); @@ -6769,6 +6786,8 @@ value_range_base::upper_bound (unsigned pair) const else gcc_unreachable (); } + else + t = m_max; return wi::to_wide (t); } diff --git a/gcc/tree-vrp.h b/gcc/tree-vrp.h index 4e8c0bc..875c506 100644 --- a/gcc/tree-vrp.h +++ b/gcc/tree-vrp.h @@ -170,6 +170,7 @@ class GTY((user)) value_range : public value_range_base /* Misc methods. */ void deep_copy (const value_range *); void dump (FILE *) const; + void dump () const; private: /* Deep-copies bitmap argument. */ @@ -354,12 +355,10 @@ void range_fold_unary_expr (value_range_base *, enum tree_code, tree, inline bool range_includes_zero_p (const value_range_base *vr) { + /* UNDEFINED may not have a type in uninitialized ranges. */ if (vr->undefined_p ()) return false; - if (vr->varying_p ()) - return true; - return vr->may_contain_p (build_zero_cst (vr->type ())); } diff --git a/gcc/vr-values.c b/gcc/vr-values.c index 8c22f7d..a4fb83e 100644 --- a/gcc/vr-values.c +++ b/gcc/vr-values.c @@ -188,10 +188,11 @@ vr_values::set_defs_to_varying (gimple *stmt) ssa_op_iter i; tree def; FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF) - { - value_range *vr = get_value_range (def); - vr->set_varying (TREE_TYPE (def)); - } + if (irange::supports_type_p (TREE_TYPE (def))) + { + value_range *vr = get_value_range (def); + vr->set_varying (TREE_TYPE (def)); + } } /* Update the value range and equivalence set for variable VAR to |