From patchwork Wed Apr 26 08:33:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1773941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Z+TqFmHJ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q5sdc4QYrz23vG for ; Wed, 26 Apr 2023 18:35:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D591385020B for ; Wed, 26 Apr 2023 08:35:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D591385020B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682498146; bh=udbvdY9yuO5H6nBnER8VOwvcQSeuEnyabwcWHjuNptE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Z+TqFmHJxidAO6CwoiLejcZYjBxCUpPiAH63FamuEeTPlvK9DRVgwBj2TGbWWKfIj 5mNmVPGK/GChzgo9nxTsO3qQfixS4p1d0/YQKPS0WzIugZLYKpsy9VeCeD/978nA6s KV+AGmM1gzZolmWxdaXxUM5xifSzMnyjPoOw2puw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id AC5C23857835 for ; Wed, 26 Apr 2023 08:34:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AC5C23857835 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-EjNVHfdvNsqiNMY5wU1OdA-1; Wed, 26 Apr 2023 04:34:17 -0400 X-MC-Unique: EjNVHfdvNsqiNMY5wU1OdA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C83B8185A78F for ; Wed, 26 Apr 2023 08:34:16 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0ADD492B03; Wed, 26 Apr 2023 08:34:15 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 33Q8YE7s313624 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 10:34:14 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33Q8YEZB313623; Wed, 26 Apr 2023 10:34:14 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Remove symbolics from irange. Date: Wed, 26 Apr 2023 10:33:26 +0200 Message-Id: <20230426083328.313566-7-aldyh@redhat.com> In-Reply-To: <20230426083328.313566-1-aldyh@redhat.com> References: <20230426083328.313566-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. --- 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;