From patchwork Thu May 16 10:01:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1935921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=NBrz8pj0; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vg5H467lmz1ymw for ; Thu, 16 May 2024 20:02:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 175F13849AFF for ; Thu, 16 May 2024 10:02:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-44.mimecast.com (us-smtp-delivery-44.mimecast.com [207.211.30.44]) by sourceware.org (Postfix) with ESMTPS id 3B8E5384640C for ; Thu, 16 May 2024 10:01:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B8E5384640C Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=localhost.redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3B8E5384640C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=207.211.30.44 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715853705; cv=none; b=NRWQVn9h5t7k+zzXGX07kGiJq1HTpnm8Hd7jnSk/g0JMJULmycxOGOvGFihYZ7AnGcJlN6NR6/vihw2l0Fn9BofDH7geNZ43DmVnKf9srjbgvlS0ySXrSJvBakwel+F+FWJZvJqCK3taQRdafSqiq5Xv687D24LO8tdga4SfU6o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715853705; c=relaxed/simple; bh=Wzk9vknlsL4b6sU45Q605CytP58lgASVzUYJlKCxAoQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eHI8ikbJfOtn18VcYQqUl0J9+JFG9CIWSXkVrMNDOzGDKem+rZKb1rGhuhl5f6a8ylAFut3JoVOyCNz7fVNnX+6MTEQ5NgM1LTk4vhlCo07xCPI+3w0sf2DnLKUjhn/G7XEcBu25DvWVJ4S5I2OlnxCTAZMunO9RRFLPqfjF5vI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715853702; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CWd3pr0xDjYwZo+OgNXUZgFRQYbtI2EX9kuDxTbjX10=; b=NBrz8pj08B9Hcjn1p4XLQz++q6A5fRdZMB1PvRaIB6twNtJFd7bKkGdwBXIfxRuTUJJn9Y Aj2TAZgE0sKC9Rju/pJ4TD463RXPKWzCM8dRB8C6rmYrJHXwnqvbiqd1sZVhLpsr1t3Q1q K9aVMwYbCm8fNMHw/xK204no3dxdkUs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63--RYglnxmOeC-J_T-KZakWQ-1; Thu, 16 May 2024 06:01:24 -0400 X-MC-Unique: -RYglnxmOeC-J_T-KZakWQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16FC21C0150C; Thu, 16 May 2024 10:01:24 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.255]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC4BF200A08E; Thu, 16 May 2024 10:01:23 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.18.1/8.17.1) with ESMTPS id 44GA1MpW938229 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 16 May 2024 12:01:22 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.18.1/8.18.1/Submit) id 44GA1M2R938228; Thu, 16 May 2024 12:01:22 +0200 From: Aldy Hernandez To: GCC patches Cc: Martin Jambor , Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Revert "Revert: "Enable prange support."" Date: Thu, 16 May 2024 12:01:01 +0200 Message-ID: <20240516100118.938171-3-aldyh@redhat.com> In-Reply-To: <20240516100118.938171-1-aldyh@redhat.com> References: <20240516100118.938171-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This reverts commit d7bb8eaade3cd3aa70715c8567b4d7b08098e699 and enables prange support again. --- gcc/gimple-range-cache.cc | 4 ++-- gcc/gimple-range-fold.cc | 4 ++-- gcc/gimple-range-fold.h | 2 +- gcc/gimple-range-infer.cc | 2 +- gcc/gimple-range-op.cc | 2 +- gcc/gimple-range-path.cc | 2 +- gcc/gimple-ssa-warn-access.cc | 2 +- gcc/ipa-cp.h | 2 +- gcc/range-op-ptr.cc | 4 ---- gcc/range-op.cc | 18 ++++-------------- gcc/tree-ssa-structalias.cc | 2 +- gcc/value-range.cc | 1 + gcc/value-range.h | 4 ++-- 13 files changed, 18 insertions(+), 31 deletions(-) diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc index 72ac2552311..bdd2832873a 100644 --- a/gcc/gimple-range-cache.cc +++ b/gcc/gimple-range-cache.cc @@ -274,10 +274,10 @@ sbr_sparse_bitmap::sbr_sparse_bitmap (tree t, vrange_allocator *allocator, // Pre-cache zero and non-zero values for pointers. if (POINTER_TYPE_P (t)) { - int_range<2> nonzero; + prange nonzero; nonzero.set_nonzero (t); m_range[1] = m_range_allocator->clone (nonzero); - int_range<2> zero; + prange zero; zero.set_zero (t); m_range[2] = m_range_allocator->clone (zero); } diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 9c4ad1ee7b9..a9c8c4d03e6 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -597,7 +597,7 @@ fold_using_range::fold_stmt (vrange &r, gimple *s, fur_source &src, tree name) // Process addresses. if (gimple_code (s) == GIMPLE_ASSIGN && gimple_assign_rhs_code (s) == ADDR_EXPR) - return range_of_address (as_a (r), s, src); + return range_of_address (as_a (r), s, src); gimple_range_op_handler handler (s); if (handler) @@ -757,7 +757,7 @@ fold_using_range::range_of_range_op (vrange &r, // If a range cannot be calculated, set it to VARYING and return true. bool -fold_using_range::range_of_address (irange &r, gimple *stmt, fur_source &src) +fold_using_range::range_of_address (prange &r, gimple *stmt, fur_source &src) { gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN); gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR); diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h index 7cbe15d05e5..c7c599bfc93 100644 --- a/gcc/gimple-range-fold.h +++ b/gcc/gimple-range-fold.h @@ -157,7 +157,7 @@ protected: fur_source &src); bool range_of_call (vrange &r, gcall *call, fur_source &src); bool range_of_cond_expr (vrange &r, gassign* cond, fur_source &src); - bool range_of_address (irange &r, gimple *s, fur_source &src); + bool range_of_address (prange &r, gimple *s, fur_source &src); bool range_of_phi (vrange &r, gphi *phi, fur_source &src); void range_of_ssa_name_with_loop_info (vrange &, tree, class loop *, gphi *, fur_source &src); diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc index c8e8b9b60ac..d5e1aa14275 100644 --- a/gcc/gimple-range-infer.cc +++ b/gcc/gimple-range-infer.cc @@ -123,7 +123,7 @@ gimple_infer_range::add_nonzero (tree name) { if (!gimple_range_ssa_p (name)) return; - int_range<2> nz; + prange nz; nz.set_nonzero (TREE_TYPE (name)); add_range (name, nz); } diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 7321342b00d..aec3f39ec0e 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -1107,7 +1107,7 @@ class cfn_strlen : public range_operator { public: using range_operator::fold_range; - virtual bool fold_range (irange &r, tree type, const irange &, + virtual bool fold_range (irange &r, tree type, const prange &, const irange &, relation_trio) const { wide_int max = irange_val_max (ptrdiff_type_node); diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index 96c6ac6b6a5..f1a12f76144 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -443,7 +443,7 @@ path_range_query::compute_ranges_in_block (basic_block bb) void path_range_query::adjust_for_non_null_uses (basic_block bb) { - int_range_max r; + prange r; bitmap_iterator bi; unsigned i; diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc index 2c10d19e7f3..0cd5b6d6ef4 100644 --- a/gcc/gimple-ssa-warn-access.cc +++ b/gcc/gimple-ssa-warn-access.cc @@ -4213,7 +4213,7 @@ pass_waccess::check_pointer_uses (gimple *stmt, tree ptr, where the realloc call is known to have failed are valid. Ignore pointers that nothing is known about. Those could have escaped along with their nullness. */ - value_range vr; + prange vr; if (m_ptr_qry.rvals->range_of_expr (vr, realloc_lhs, use_stmt)) { if (vr.zero_p ()) diff --git a/gcc/ipa-cp.h b/gcc/ipa-cp.h index abeaaa4053e..e62a09f38af 100644 --- a/gcc/ipa-cp.h +++ b/gcc/ipa-cp.h @@ -296,7 +296,7 @@ bool values_equal_for_ipcp_p (tree x, tree y); static inline bool ipa_supports_p (tree type) { - return irange::supports_p (type); + return irange::supports_p (type) || prange::supports_p (type); } #endif /* IPA_CP_H */ diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc index c24097a1c30..9421d3cd21d 100644 --- a/gcc/range-op-ptr.cc +++ b/gcc/range-op-ptr.cc @@ -1684,8 +1684,4 @@ range_op_table::initialize_pointer_ops () { set (POINTER_PLUS_EXPR, op_pointer_plus); set (POINTER_DIFF_EXPR, op_pointer_diff); - set (BIT_AND_EXPR, op_hybrid_and); - set (BIT_IOR_EXPR, op_hybrid_or); - set (MIN_EXPR, op_hybrid_min); - set (MAX_EXPR, op_hybrid_max); } diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 852d59c20e9..d188d1a1b63 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -102,23 +102,13 @@ range_op_table::range_op_table () set (MINUS_EXPR, op_minus); set (NEGATE_EXPR, op_negate); set (MULT_EXPR, op_mult); - - // Occur in both integer and pointer tables, but currently share - // integral implementation. set (ADDR_EXPR, op_addr); set (BIT_NOT_EXPR, op_bitwise_not); set (BIT_XOR_EXPR, op_bitwise_xor); - - // These are in both integer and pointer tables, but pointer has a different - // implementation. - // If commented out, there is a hybrid version in range-op-ptr.cc which - // is used until there is a pointer range class. Then we can simply - // uncomment the operator here and use the unified version. - - // set (BIT_AND_EXPR, op_bitwise_and); - // set (BIT_IOR_EXPR, op_bitwise_or); - // set (MIN_EXPR, op_min); - // set (MAX_EXPR, op_max); + set (BIT_AND_EXPR, op_bitwise_and); + set (BIT_IOR_EXPR, op_bitwise_or); + set (MIN_EXPR, op_min); + set (MAX_EXPR, op_max); } // Instantiate a default range operator for opcodes with no entry. diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc index 9c63305063c..bb59c6a7c02 100644 --- a/gcc/tree-ssa-structalias.cc +++ b/gcc/tree-ssa-structalias.cc @@ -6833,7 +6833,7 @@ find_what_p_points_to (tree fndecl, tree p) struct ptr_info_def *pi; tree lookup_p = p; varinfo_t vi; - value_range vr; + prange vr; get_range_query (DECL_STRUCT_FUNCTION (fndecl))->range_of_expr (vr, p); bool nonnull = vr.nonzero_p (); diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 5bcb2c3f650..334ffb70fbc 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -1518,6 +1518,7 @@ irange::verify_range () gcc_checking_assert (m_num_ranges == 0); return; } + gcc_checking_assert (supports_p (type ())); gcc_checking_assert (m_num_ranges <= m_max_ranges); // Legacy allowed these to represent VARYING for unknown types. diff --git a/gcc/value-range.h b/gcc/value-range.h index 37ce91dc52d..44cdbd717f4 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -994,7 +994,7 @@ irange::varying_compatible_p () const const wide_int &u = m_base[1]; tree t = m_type; - if (m_kind == VR_VARYING && t == error_mark_node) + if (m_kind == VR_VARYING) return true; unsigned prec = TYPE_PRECISION (t); @@ -1039,7 +1039,7 @@ irange::nonzero_p () const inline bool irange::supports_p (const_tree type) { - return INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type); + return INTEGRAL_TYPE_P (type); } inline bool