From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id BE92338768AE; Wed, 26 Apr 2023 08:36:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE92338768AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682498208; bh=gKgNdMZXsdM3weEEjo6jaqBq2oqfaLEoIZEcDVMg6yE=; h=From:To:Subject:Date:From; b=mCd/VSZ4nKo9YdOEIkWCqANOPAEibpc39KPq4plvhX8HcN4rpM7YdLlJAu8xALwOU /9EwTb6SskNmkydXkLQWLKUy7773FxUD2o+HpKj5mgR9zZn9dIxIFGqT7V8Bmqzm8N nTc5xX7cpZs7qCf3s/UoC5zwC7fqb+jUVDznMkPI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-252] Remove symbolics from irange. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: 983ad30d42c810e4de60ae5ba468334ef8aa14d2 X-Git-Newrev: a38bb14f013e96e7225f904d0e8b701b0b386314 Message-Id: <20230426083648.BE92338768AE@sourceware.org> Date: Wed, 26 Apr 2023 08:36:48 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a38bb14f013e96e7225f904d0e8b701b0b386314 commit r14-252-ga38bb14f013e96e7225f904d0e8b701b0b386314 Author: Aldy Hernandez Date: Mon Nov 21 11:33:44 2022 +0100 Remove symbolics from irange. gcc/ChangeLog: * value-range.cc (irange::copy_legacy_to_multi_range): Remove symbolics support. (irange::set): Same. (irange::legacy_lower_bound): Same. (irange::legacy_upper_bound): Same. (irange::contains_p): Same. (range_tests_legacy): Same. (irange::normalize_addresses): Remove. (irange::normalize_symbolics): Remove. (irange::symbolic_p): Remove. * value-range.h (class irange): Remove symbolic_p, normalize_symbolics, and normalize_addresses. * vr-values.cc (simplify_using_ranges::two_valued_val_range_p): Remove symbolics support. Diff: --- gcc/value-range.cc | 139 ++--------------------------------------------------- gcc/value-range.h | 3 -- gcc/vr-values.cc | 1 - 3 files changed, 4 insertions(+), 139 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 6c61bcefd6e..ebadea8b917 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -945,7 +945,6 @@ irange::copy_legacy_to_multi_range (const irange &src) else { value_range cst (src); - cst.normalize_symbolics (); gcc_checking_assert (cst.varying_p () || cst.kind () == VR_RANGE); set (cst.min (), cst.max ()); } @@ -1153,17 +1152,10 @@ irange::set (tree min, tree max, value_range_kind kind) } return; } - // Nothing to canonicalize for symbolic ranges. - if (TREE_CODE (min) != INTEGER_CST - || TREE_CODE (max) != INTEGER_CST) - { - m_kind = kind; - m_base[0] = min; - m_base[1] = max; - m_num_ranges = 1; - m_nonzero_mask = NULL; - return; - } + + // Symbolics are not allowed in an irange. + gcc_checking_assert (TREE_CODE (min) == INTEGER_CST + && TREE_CODE (max) == INTEGER_CST); swap_out_of_order_endpoints (min, max, kind); if (kind == VR_VARYING) @@ -1264,12 +1256,6 @@ wide_int irange::legacy_lower_bound (unsigned pair) const { gcc_checking_assert (legacy_mode_p ()); - if (symbolic_p ()) - { - value_range numeric_range (*this); - numeric_range.normalize_symbolics (); - return numeric_range.legacy_lower_bound (pair); - } gcc_checking_assert (m_num_ranges > 0); gcc_checking_assert (pair + 1 <= num_pairs ()); if (m_kind == VR_ANTI_RANGE) @@ -1291,12 +1277,6 @@ wide_int irange::legacy_upper_bound (unsigned pair) const { gcc_checking_assert (legacy_mode_p ()); - if (symbolic_p ()) - { - value_range numeric_range (*this); - numeric_range.normalize_symbolics (); - return numeric_range.legacy_upper_bound (pair); - } gcc_checking_assert (m_num_ranges > 0); gcc_checking_assert (pair + 1 <= num_pairs ()); if (m_kind == VR_ANTI_RANGE) @@ -1371,16 +1351,6 @@ irange::operator== (const irange &other) const return nz1 == nz2; } -/* Return TRUE if this is a symbolic range. */ - -bool -irange::symbolic_p () const -{ - return (m_num_ranges > 0 - && (!is_gimple_min_invariant (min ()) - || !is_gimple_min_invariant (max ()))); -} - /* Return TRUE if this is a constant range. */ bool @@ -1492,12 +1462,6 @@ irange::contains_p (tree cst) const if (legacy_mode_p ()) { gcc_checking_assert (TREE_CODE (cst) == INTEGER_CST); - if (symbolic_p ()) - { - value_range numeric_range (*this); - numeric_range.normalize_symbolics (); - return numeric_range.contains_p (cst); - } return value_inside_range (cst) == 1; } @@ -1524,86 +1488,6 @@ irange::contains_p (tree cst) const return false; } - -/* Normalize addresses into constants. */ - -void -irange::normalize_addresses () -{ - if (undefined_p ()) - return; - - if (!POINTER_TYPE_P (type ()) || range_has_numeric_bounds_p (this)) - return; - - if (!range_includes_zero_p (this)) - { - gcc_checking_assert (TREE_CODE (min ()) == ADDR_EXPR - || TREE_CODE (max ()) == ADDR_EXPR); - set_nonzero (type ()); - return; - } - set_varying (type ()); -} - -/* Normalize symbolics and addresses into constants. */ - -void -irange::normalize_symbolics () -{ - if (varying_p () || undefined_p ()) - return; - - tree ttype = type (); - bool min_symbolic = !is_gimple_min_invariant (min ()); - bool max_symbolic = !is_gimple_min_invariant (max ()); - if (!min_symbolic && !max_symbolic) - { - normalize_addresses (); - return; - } - - // [SYM, SYM] -> VARYING - if (min_symbolic && max_symbolic) - { - set_varying (ttype); - return; - } - if (kind () == VR_RANGE) - { - // [SYM, NUM] -> [-MIN, NUM] - if (min_symbolic) - { - set (vrp_val_min (ttype), max ()); - return; - } - // [NUM, SYM] -> [NUM, +MAX] - set (min (), vrp_val_max (ttype)); - return; - } - gcc_checking_assert (kind () == VR_ANTI_RANGE); - // ~[SYM, NUM] -> [NUM + 1, +MAX] - if (min_symbolic) - { - if (!vrp_val_is_max (max ())) - { - tree n = wide_int_to_tree (ttype, wi::to_wide (max ()) + 1); - set (n, vrp_val_max (ttype)); - return; - } - set_varying (ttype); - return; - } - // ~[NUM, SYM] -> [-MIN, NUM - 1] - if (!vrp_val_is_min (min ())) - { - tree n = wide_int_to_tree (ttype, wi::to_wide (min ()) - 1); - set (vrp_val_min (ttype), n); - return; - } - set_varying (ttype); -} - /* Intersect the two value-ranges { *VR0TYPE, *VR0MIN, *VR0MAX } and { VR1TYPE, VR0MIN, VR0MAX } and store the result in { *VR0TYPE, *VR0MIN, *VR0MAX }. This may not be the smallest @@ -3525,21 +3409,6 @@ range_tests_legacy () small = big; ASSERT_TRUE (small == int_range<1> (INT (21), INT (21), VR_ANTI_RANGE)); - // Copying a legacy symbolic to an int_range should normalize the - // symbolic at copy time. - { - tree ssa = make_ssa_name (integer_type_node); - value_range legacy_range (ssa, INT (25)); - int_range<2> copy = legacy_range; - ASSERT_TRUE (copy == int_range<2> (vrp_val_min (integer_type_node), - INT (25))); - - // Test that copying ~[abc_23, abc_23] to a multi-range yields varying. - legacy_range = value_range (ssa, ssa, VR_ANTI_RANGE); - copy = legacy_range; - ASSERT_TRUE (copy.varying_p ()); - } - // VARYING of different sizes should not be equal. tree big_type = build_nonstandard_integer_type (32, 1); tree small_type = build_nonstandard_integer_type (16, 1); diff --git a/gcc/value-range.h b/gcc/value-range.h index 929dc551aa2..1012d007261 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -169,10 +169,7 @@ public: // Deprecated legacy public methods. tree min () const; // DEPRECATED tree max () const; // DEPRECATED - bool symbolic_p () const; // DEPRECATED bool constant_p () const; // DEPRECATED - void normalize_symbolics (); // DEPRECATED - void normalize_addresses (); // DEPRECATED bool legacy_verbose_union_ (const class irange *); // DEPRECATED bool legacy_verbose_intersect (const irange *); // DEPRECATED diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc index 841bcd1acb9..ba569b3f72f 100644 --- a/gcc/vr-values.cc +++ b/gcc/vr-values.cc @@ -2161,7 +2161,6 @@ simplify_using_ranges::two_valued_val_range_p (tree var, tree *a, tree *b, value_range vr; if (!query->range_of_expr (vr, var, s)) return false; - vr.normalize_symbolics (); if (vr.varying_p () || vr.undefined_p ()) return false;