From patchwork Fri Nov 11 13:53:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 60413 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87185388B6A7 for ; Fri, 11 Nov 2022 13:54:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87185388B6A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668174844; bh=N1bYPqlfVhwJcBmr9Dl+Eo9snKpPmY4xM/qJtupJWNI=; 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=axn7lOyIu7hpzz4WtIYtT4T0G48CSqfGbP0w9Sw3lZClWlDNkAgO69Nqsj4GyUVFD ZaVqC1fGWpxS0TY6VfW5JWuW+kz7l53j2RJ22vopUYkXn9pWueyDgGpOGXViTaxIZN fjihbEzTA49VjczgCTLjYRi2AZOUlN+tOGHZ24ck= 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 978A03858C52 for ; Fri, 11 Nov 2022 13:53:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 978A03858C52 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-108-NJHnPhrjOBmjsZrvHayB5g-1; Fri, 11 Nov 2022 08:53:26 -0500 X-MC-Unique: NJHnPhrjOBmjsZrvHayB5g-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 68572811E67 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 20366140EBF5; 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 2ABDrOmh235451 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Nov 2022 14:53:24 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 2ABDrON9235450; Fri, 11 Nov 2022 14:53:24 +0100 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] [range-ops] Use existing tree code for *DIV_EXPR entries. Date: Fri, 11 Nov 2022 14:53:15 +0100 Message-Id: <20221111135318.235387-2-aldyh@redhat.com> In-Reply-To: <20221111135318.235387-1-aldyh@redhat.com> References: <20221111135318.235387-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" There is no need for a special tree code in the *DIV_EXPR entries, as the parent class has one. gcc/ChangeLog: * range-op.cc (class operator_div): Remove tree code. (operator_div::wi_op_overflows): Handle EXACT_DIV_EXPR as TRUNC_DIV_EXPR. --- gcc/range-op.cc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/gcc/range-op.cc b/gcc/range-op.cc index 1fbebd85620..00a736e983d 100644 --- a/gcc/range-op.cc +++ b/gcc/range-op.cc @@ -1971,7 +1971,6 @@ operator_mult::wi_fold (irange &r, tree type, class operator_div : public cross_product_operator { public: - operator_div (enum tree_code c) { code = c; } virtual void wi_fold (irange &r, tree type, const wide_int &lh_lb, const wide_int &lh_ub, @@ -1983,8 +1982,6 @@ public: virtual bool fold_range (irange &r, tree type, const irange &lh, const irange &rh, relation_trio trio) const final override; -private: - enum tree_code code; }; bool @@ -1995,7 +1992,7 @@ operator_div::fold_range (irange &r, tree type, if (!cross_product_operator::fold_range (r, type, lh, rh, trio)) return false; - update_known_bitmask (r, code, lh, rh); + update_known_bitmask (r, m_code, lh, rh); return true; } @@ -2009,13 +2006,9 @@ operator_div::wi_op_overflows (wide_int &res, tree type, wi::overflow_type overflow = wi::OVF_NONE; signop sign = TYPE_SIGN (type); - switch (code) + switch (m_code) { case EXACT_DIV_EXPR: - // EXACT_DIV_EXPR is implemented as TRUNC_DIV_EXPR in - // operator_exact_divide. No need to handle it here. - gcc_unreachable (); - break; case TRUNC_DIV_EXPR: res = wi::div_trunc (w0, w1, sign, &overflow); break; @@ -2091,17 +2084,11 @@ operator_div::wi_fold (irange &r, tree type, gcc_checking_assert (!r.undefined_p ()); } -operator_div op_trunc_div (TRUNC_DIV_EXPR); -operator_div op_floor_div (FLOOR_DIV_EXPR); -operator_div op_round_div (ROUND_DIV_EXPR); -operator_div op_ceil_div (CEIL_DIV_EXPR); - class operator_exact_divide : public operator_div { using range_operator::op1_range; public: - operator_exact_divide () : operator_div (TRUNC_DIV_EXPR) { } virtual bool op1_range (irange &r, tree type, const irange &lhs, const irange &op2, @@ -4382,6 +4369,10 @@ 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; +static operator_div op_trunc_div; +static operator_div op_floor_div; +static operator_div op_round_div; +static operator_div op_ceil_div; // Instantiate a range op table for integral operations.