From patchwork Fri Nov 11 13:53:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1702650 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=8.43.85.97; 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=btMJvlqy; dkim-atps=neutral Received: from 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 (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N80YC3vkhz23lT for ; Sat, 12 Nov 2022 00:53:51 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C07C9384606C for ; Fri, 11 Nov 2022 13:53:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C07C9384606C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668174828; bh=ZYo9FpJBpOgjdR0x/ShOsEyiqEP4XDfFYDkno2QyyFk=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=btMJvlqyHdaEi0HJyv9ABP3AoXu5o9cu88+d4/unOFcdsLTEbsYw+Dyqz2WcGyNPb suCSau3nXbZDFIxZPM+rLn9hpXsDtFqli7px+3qYKFvCBdz22hjzEWY7iA+hAAMP/f Wzz70Ne82XZl58AmmrRnqOXt9l6aHLJnaXmH4/Yw= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id EB4AE3858D1E for ; Fri, 11 Nov 2022 13:53:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EB4AE3858D1E 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-647-J9KgApqOOlKdu9khqo22lA-1; Fri, 11 Nov 2022 08:53:26 -0500 X-MC-Unique: J9KgApqOOlKdu9khqo22lA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 22281811E75 for ; Fri, 11 Nov 2022 13:53:26 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.220]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CBBC2C1D3AD; Fri, 11 Nov 2022 13:53:25 +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 2ABDrNxH235447 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 14:53:23 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 2ABDrNVM235446; Fri, 11 Nov 2022 14:53:23 +0100 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [range-ops] Add tree code to range_operator. Date: Fri, 11 Nov 2022 14:53:14 +0100 Message-Id: <20221111135318.235387-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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 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" This patch adds a tree code to range_operator in order to known which tree code to pass into bit-CCP. Up to now range-ops has been free of tree details, with the exception of the div entries which use a tree code to differentiate between them. This is still the goal going forward, but this is a stop-gap until we can merge the CCP and range-op bit handling in the next release. No change in performance. gcc/ChangeLog: * range-op.cc: (range_op_table::set): Set m_code. (integral_table::integral_table): Handle shared entries. (pointer_table::pointer_table): Same. * range-op.h (class range_operator): Add m_code. --- gcc/range-op.cc | 37 +++++++++++++++++++++++-------------- gcc/range-op.h | 5 +++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 8ff5d5b4c78..1fbebd85620 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -2523,7 +2523,7 @@ private: const irange &outer) const; void fold_pair (irange &r, unsigned index, const irange &inner, const irange &outer) const; -} op_convert; +}; // Add a partial equivalence between the LHS and op1 for casts. @@ -3877,7 +3877,7 @@ public: const irange &op1, const irange &op2, relation_kind rel) const; -} op_identity; +}; // Determine if there is a relationship between LHS and OP1. @@ -3922,7 +3922,7 @@ public: const irange &op1, const irange &op2, relation_trio rel = TRIO_VARYING) const; -} op_unknown; +}; bool operator_unknown::fold_range (irange &r, tree type, @@ -4245,7 +4245,7 @@ public: virtual void wi_fold (irange & r, tree type, const wide_int &lh_lb, const wide_int &lh_ub, const wide_int &rh_lb, const wide_int &rh_ub) const; -} op_ptr_min_max; +}; void pointer_min_max_operator::wi_fold (irange &r, tree type, @@ -4372,8 +4372,17 @@ range_op_table::set (enum tree_code code, range_operator &op) { gcc_checking_assert (m_range_tree[code] == NULL); m_range_tree[code] = &op; + gcc_checking_assert (op.m_code == ERROR_MARK || op.m_code == code); + op.m_code = code; } +// Shared operators that require separate instantiations because they +// do not share a common tree code. +static operator_cast op_nop, op_convert; +static operator_identity op_ssa, op_paren, op_obj_type; +static operator_unknown op_realpart, op_imagpart; +static pointer_min_max_operator op_ptr_min, op_ptr_max; + // Instantiate a range op table for integral operations. class integral_table : public range_op_table @@ -4402,7 +4411,7 @@ integral_table::integral_table () set (EXACT_DIV_EXPR, op_exact_div); set (LSHIFT_EXPR, op_lshift); set (RSHIFT_EXPR, op_rshift); - set (NOP_EXPR, op_convert); + set (NOP_EXPR, op_nop); set (CONVERT_EXPR, op_convert); set (TRUTH_AND_EXPR, op_logical_and); set (BIT_AND_EXPR, op_bitwise_and); @@ -4413,11 +4422,11 @@ integral_table::integral_table () set (TRUTH_NOT_EXPR, op_logical_not); set (BIT_NOT_EXPR, op_bitwise_not); set (INTEGER_CST, op_integer_cst); - set (SSA_NAME, op_identity); - set (PAREN_EXPR, op_identity); - set (OBJ_TYPE_REF, op_identity); - set (IMAGPART_EXPR, op_unknown); - set (REALPART_EXPR, op_unknown); + set (SSA_NAME, op_ssa); + set (PAREN_EXPR, op_paren); + set (OBJ_TYPE_REF, op_obj_type); + set (IMAGPART_EXPR, op_imagpart); + set (REALPART_EXPR, op_realpart); set (POINTER_DIFF_EXPR, op_pointer_diff); set (ABS_EXPR, op_abs); set (ABSU_EXPR, op_absu); @@ -4437,8 +4446,8 @@ pointer_table::pointer_table () { set (BIT_AND_EXPR, op_pointer_and); set (BIT_IOR_EXPR, op_pointer_or); - set (MIN_EXPR, op_ptr_min_max); - set (MAX_EXPR, op_ptr_min_max); + set (MIN_EXPR, op_ptr_min); + set (MAX_EXPR, op_ptr_max); set (POINTER_PLUS_EXPR, op_pointer_plus); set (EQ_EXPR, op_equal); @@ -4447,10 +4456,10 @@ pointer_table::pointer_table () set (LE_EXPR, op_le); set (GT_EXPR, op_gt); set (GE_EXPR, op_ge); - set (SSA_NAME, op_identity); + set (SSA_NAME, op_ssa); set (INTEGER_CST, op_integer_cst); set (ADDR_EXPR, op_addr); - set (NOP_EXPR, op_convert); + set (NOP_EXPR, op_nop); set (CONVERT_EXPR, op_convert); set (BIT_NOT_EXPR, op_bitwise_not); diff --git a/gcc/range-op.h b/gcc/range-op.h index 442a6e1d299..c999b456f62 100644 --- a/gcc/range-op.h +++ b/gcc/range-op.h @@ -48,7 +48,9 @@ along with GCC; see the file COPYING3. If not see class range_operator { + friend class range_op_table; public: + range_operator () : m_code (ERROR_MARK) { } // Perform an operation between 2 ranges and return it. virtual bool fold_range (irange &r, tree type, const irange &lh, @@ -106,6 +108,9 @@ protected: const wide_int &lh_ub, const wide_int &rh_lb, const wide_int &rh_ub) const; + + // Tree code of the range operator or ERROR_MARK if unknown. + tree_code m_code; }; // Like range_operator above, but for floating point operators.