From patchwork Tue Apr 18 12:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1770167 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=D/5ob6Pw; 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 4Q13tV2kX0z1ybC for ; Tue, 18 Apr 2023 23:00:16 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B21EE3858C60 for ; Tue, 18 Apr 2023 13:00:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B21EE3858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681822814; bh=9TnMfAKvrLW8ITF8HGhdW+oML3d5Rt6F8h1uWhhmMOs=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=D/5ob6PwzAfXLlraqfndc6SijCgTUzkkCI5NnCxBiiiko5zpoKgDtXnpcBJTy7knH W5jMzMhB0PUcPAtXZYBXrnLhhe+pt2oP747nrRuD2Ffsb6dY+7zLWAmnGR3VFHY++3 E1f2Qd92RPHyVJMgnxyhTqVTSDHmBkqUmH2OyPDE= 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 B912E3858C2C for ; Tue, 18 Apr 2023 12:59:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B912E3858C2C 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-519-IP7mhuJdMHiJZRzGnlAT7A-1; Tue, 18 Apr 2023 08:59:54 -0400 X-MC-Unique: IP7mhuJdMHiJZRzGnlAT7A-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 E9CBD10AF807 for ; Tue, 18 Apr 2023 12:59:53 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 827BF492C3E; Tue, 18 Apr 2023 12:59:53 +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 33ICxp28307490 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 18 Apr 2023 14:59:51 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33ICxoup307489; Tue, 18 Apr 2023 14:59:50 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [PATCH] Declare dconstm0 to go along with dconst0 and friends. Date: Tue, 18 Apr 2023 14:59:28 +0200 Message-Id: <20230418125928.307445-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.3 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" Negating dconst0 is getting pretty old, and we will keep adding copies of the same idiom. Fixed by adding a dconstm0 constant to go along with dconst1, dconstm1, etc. OK for trunk? gcc/ChangeLog: * emit-rtl.cc (init_emit_once): Initialize dconstm0. * gimple-range-op.cc (class cfn_signbit): Remove dconstm0 declaration. * range-op-float.cc (zero_range): Use dconstm0. (zero_to_inf_range): Same. * real.h (dconstm0): New. * value-range.cc (frange::flush_denormals_to_zero): Use dconstm0. (frange::set_zero): Do not declare dconstm0. --- gcc/emit-rtl.cc | 4 ++++ gcc/gimple-range-op.cc | 2 -- gcc/range-op-float.cc | 6 +++--- gcc/real.h | 1 + gcc/value-range.cc | 7 +++---- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gcc/emit-rtl.cc b/gcc/emit-rtl.cc index a11f72f606b..4036f4b64f7 100644 --- a/gcc/emit-rtl.cc +++ b/gcc/emit-rtl.cc @@ -105,6 +105,7 @@ rtx const_true_rtx; REAL_VALUE_TYPE dconst0; REAL_VALUE_TYPE dconst1; REAL_VALUE_TYPE dconst2; +REAL_VALUE_TYPE dconstm0; REAL_VALUE_TYPE dconstm1; REAL_VALUE_TYPE dconsthalf; REAL_VALUE_TYPE dconstinf; @@ -6206,6 +6207,9 @@ init_emit_once (void) real_from_integer (&dconst1, double_mode, 1, SIGNED); real_from_integer (&dconst2, double_mode, 2, SIGNED); + dconstm0 = dconst0; + dconstm0.sign = 1; + dconstm1 = dconst1; dconstm1.sign = 1; diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc index 4ca32a7b5d5..f7409e35a99 100644 --- a/gcc/gimple-range-op.cc +++ b/gcc/gimple-range-op.cc @@ -360,8 +360,6 @@ public: } if (!lhs.contains_p (build_zero_cst (lhs.type ()))) { - REAL_VALUE_TYPE dconstm0 = dconst0; - dconstm0.sign = 1; r.set (type, frange_val_min (type), dconstm0); r.update_nan (true); return true; diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index e0e91bad44d..9d184611ae9 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -2263,7 +2263,7 @@ zero_range (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, int signbit_known) { ub = lb = dconst0; if (signbit_known <= 0) - lb = real_value_negate (&dconst0); + lb = dconstm0; if (signbit_known < 0) ub = lb; } @@ -2297,7 +2297,7 @@ zero_to_inf_range (REAL_VALUE_TYPE &lb, REAL_VALUE_TYPE &ub, int signbit_known) else if (signbit_known < 0) { lb = dconstninf; - ub = real_value_negate (&dconst0); + ub = dconstm0; } else { @@ -2634,7 +2634,7 @@ private: if (real_isneg (&lh_lb) == real_isneg (&lh_ub)) cp[1] = dconst0; else - cp[1] = real_value_negate (&dconst0); + cp[1] = dconstm0; } else cp[1] = cp[0]; diff --git a/gcc/real.h b/gcc/real.h index dd41c65d786..9e02139ad63 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -468,6 +468,7 @@ extern void real_ldexp (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int); extern REAL_VALUE_TYPE dconst0; extern REAL_VALUE_TYPE dconst1; extern REAL_VALUE_TYPE dconst2; +extern REAL_VALUE_TYPE dconstm0; extern REAL_VALUE_TYPE dconstm1; extern REAL_VALUE_TYPE dconsthalf; extern REAL_VALUE_TYPE dconstinf; diff --git a/gcc/value-range.cc b/gcc/value-range.cc index c14a27e23af..34817fc0159 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -322,9 +322,10 @@ frange::flush_denormals_to_zero () // Flush [x, -DENORMAL] to [x, -0.0]. if (real_isdenormal (&m_max, mode) && real_isneg (&m_max)) { - m_max = dconst0; if (HONOR_SIGNED_ZEROS (m_type)) - m_max.sign = 1; + m_max = dconstm0; + else + m_max = dconst0; } // Flush [+DENORMAL, x] to [+0.0, x]. if (real_isdenormal (&m_min, mode) && !real_isneg (&m_min)) @@ -840,8 +841,6 @@ frange::set_zero (tree type) { if (HONOR_SIGNED_ZEROS (type)) { - REAL_VALUE_TYPE dconstm0 = dconst0; - dconstm0.sign = 1; set (type, dconstm0, dconst0); clear_nan (); }