From patchwork Wed Sep 14 15:08:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1211 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2302:b0:79:6ae5:3758 with SMTP id gv2csp743109dyb; Wed, 14 Sep 2022 08:10:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR4+KnUNKJvAnim25R6SMk+FjhqOuY+/rSKJxZut4ktqNjO+86gYk9eCs3yMGKwlARGXS/VN X-Received: by 2002:a17:907:2e02:b0:77b:bdab:674b with SMTP id ig2-20020a1709072e0200b0077bbdab674bmr13498894ejc.159.1663168236217; Wed, 14 Sep 2022 08:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663168236; cv=none; d=google.com; s=arc-20160816; b=JkjQpsZw669GBssWG8HUD9WmZuP04+t4pLwLPU4iUTeGbDiKPBuHHLBupfphbg7Tye Js4w9m8CioMdpuCIKYKOxtmfj9DkSjx/c6tFeVbjP/0TdMawWnffhAPS9G68Hb9e7eIJ FMdDO/DJJWkWpKlsOZ+/il6K2XSTw60M2luwqMEu3IBLg/C+ENmv7C5q7LvKeo2ESg7M DdYQ4Apj/SpaZ4CDiN+6RNFB/HiIugMx1DAHLIRwd+J9T8m7VuHrvHyl/ryTbwGnSAhX hikre9L/ckVC0WjTDQksE1+DCnpOCKWfflfHhVGoSzcPXQYfS3If4KS4wLqTqx+vPZzH O2SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=I34hro3Mr5mYQtNl3jAwufTCVBBJIazJThKDRrZ2fWE=; b=LLWOH494hVQ60pNVdPnSltv0B8v9On2ExdKfc/j7QjjKONC9t8+HeV03siXAjPsDA7 yg0/6VPBoJyoyJ6LeEq2o1FgkqAaQcZruBDG9bDctbqEmWq8Kq2SoXz1ICnbZJ112wir cpIshU4Fg8Dg+uyuHJbMeiqWiBHlV08bR8BakCupJkqk6OWmBD7Gq9lVAG8T2+yRnqTb VaSBGU1OF8/+X8bNepcqNgNpnN0PqPr1x7Kb+PGlgtkoHcrJwc+8TDLYqVFy/ogemgxJ bQ+4Pn31YaIM5c4X7sVK93ypwoOGcObcD5Cnh8anWLq35UU2gc+aTv3CaenlFkgTd4Gj YzmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BvpBgs4+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i14-20020a1709064fce00b007803739fe1bsi1529773ejw.10.2022.09.14.08.10.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 08:10:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BvpBgs4+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64326384F02E for ; Wed, 14 Sep 2022 15:09:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64326384F02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663168185; bh=I34hro3Mr5mYQtNl3jAwufTCVBBJIazJThKDRrZ2fWE=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BvpBgs4+GM192opYW2cb7wyXAhO9boqbtevHgcxzLfTVRXHycOGW/o/BB53C+yMqL 9m2IQa8GKz04lkduDKUC3IisZiasaOGd8mX/VyI0m7GYHsAwBYT9cyTlkNy9BdFCM8 pGfrJkp18pbDVlVBT3u4gRv5hZ4Y5RKhDqfYih/U= 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 2CB98385841F for ; Wed, 14 Sep 2022 15:09:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2CB98385841F 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-482-7lFyZqWCMtaJjbkvQdFK6Q-1; Wed, 14 Sep 2022 11:09:00 -0400 X-MC-Unique: 7lFyZqWCMtaJjbkvQdFK6Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55788185A78F for ; Wed, 14 Sep 2022 15:09:00 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.40.192.189]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0102F2027063; Wed, 14 Sep 2022 15:08:59 +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 28EF8w8o1244453 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 14 Sep 2022 17:08:58 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28EF8w5k1244452; Wed, 14 Sep 2022 17:08:58 +0200 To: GCC patches Subject: [COMMITTED] Use frange::set_nan() from the generic frange::set(). Date: Wed, 14 Sep 2022 17:08:50 +0200 Message-Id: <20220914150852.1244397-3-aldyh@redhat.com> In-Reply-To: <20220914150852.1244397-1-aldyh@redhat.com> References: <20220914150852.1244397-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 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_LOW, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743958296491702882?= X-GMAIL-MSGID: =?utf-8?q?1743958296491702882?= This patch cleans up the frange::set() code by passing all things NAN to frange::set_nan(). No functional changes. Regstrapped on x86-64 Linux, plus I ran selftests for -ffinite-math-only. gcc/ChangeLog: * value-range.cc (frange::set): Use set_nan. * value-range.h (frange::set_nan): Inline code originally in set(). --- gcc/value-range.cc | 27 ++++++++++++++------------- gcc/value-range.h | 9 ++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/gcc/value-range.cc b/gcc/value-range.cc index dd827421aca..d759fcf178c 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -369,32 +369,33 @@ frange::set (tree min, tree max, value_range_kind kind) return; } + // Handle NANs. + if (real_isnan (TREE_REAL_CST_PTR (min)) || real_isnan (TREE_REAL_CST_PTR (max))) + { + gcc_checking_assert (real_identical (TREE_REAL_CST_PTR (min), + TREE_REAL_CST_PTR (max))); + tree type = TREE_TYPE (min); + set_nan (type); + return; + } + m_kind = kind; m_type = TREE_TYPE (min); m_props.set_varying (); m_min = *TREE_REAL_CST_PTR (min); m_max = *TREE_REAL_CST_PTR (max); - bool is_nan = (real_isnan (TREE_REAL_CST_PTR (min)) - || real_isnan (TREE_REAL_CST_PTR (max))); - - // Ranges with a NAN and a non-NAN endpoint are nonsensical. - gcc_checking_assert (!is_nan || operand_equal_p (min, max)); - - // Set NAN property if we're absolutely sure. - if (is_nan && operand_equal_p (min, max)) - m_props.nan_set_yes (); - else if (!HONOR_NANS (m_type)) - m_props.nan_set_no (); - // Set SIGNBIT property for positive and negative ranges. if (real_less (&m_max, &dconst0)) m_props.signbit_set_yes (); else if (real_less (&dconst0, &m_min)) m_props.signbit_set_no (); + if (!HONOR_NANS (m_type)) + m_props.nan_set_no (); + // Check for swapped ranges. - gcc_checking_assert (is_nan || tree_compare (LE_EXPR, min, max)); + gcc_checking_assert (tree_compare (LE_EXPR, min, max)); normalize_kind (); if (flag_checking) diff --git a/gcc/value-range.h b/gcc/value-range.h index 6e896eb9ab5..4392de84c8b 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -1193,7 +1193,14 @@ frange::set_nan (tree type) { REAL_VALUE_TYPE r; gcc_assert (real_nan (&r, "", 1, TYPE_MODE (type))); - set (type, r, r); + m_kind = VR_RANGE; + m_type = type; + m_min = r; + m_max = r; + m_props.set_varying (); + m_props.nan_set_yes (); + if (flag_checking) + verify_range (); } // Return TRUE if range is known to be finite.