From patchwork Thu May 25 05:35:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1785913 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=QWuJf0ik; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.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 4QRcHg5w7yz20Pb for ; Thu, 25 May 2023 15:36:47 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D48513858D3C for ; Thu, 25 May 2023 05:36:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D48513858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684993005; bh=hhoBNU3fG9f4dq/Xw87qbZIr+Womn4RWK8hq0DESrpA=; 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=QWuJf0ikm4H2eipW0alKrkzIkWePuQDKNJXtpHXHicFzzHLb4niXRNtAjOsB80RT6 tHXEZP9qjRlaH7OFXfBWB8I/Va4OKftj/FsSSWOcdwub6sKDN7Hb15kXLU1OwmZEod yGmnrOsO6tu3DD+PE5upje2oR3gM0wNlIK/Ue5Uk= 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 C15563858D20 for ; Thu, 25 May 2023 05:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C15563858D20 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-125-VLUe2pLjOlyq4IV7YGPvjg-1; Thu, 25 May 2023 01:35:26 -0400 X-MC-Unique: VLUe2pLjOlyq4IV7YGPvjg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC279101A52C for ; Thu, 25 May 2023 05:35:25 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5442240CFD00; Thu, 25 May 2023 05:35: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 34P5ZNKU244706 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 25 May 2023 07:35:23 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 34P5ZNQa244705; Thu, 25 May 2023 07:35:23 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Stream out NANs correctly. Date: Thu, 25 May 2023 07:35:20 +0200 Message-Id: <20230525053520.244673-4-aldyh@redhat.com> In-Reply-To: <20230525053520.244673-1-aldyh@redhat.com> References: <20230525053520.244673-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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" NANs don't have bounds, so there's no need to stream them out. gcc/ChangeLog: * data-streamer-in.cc (streamer_read_value_range): Handle NANs. * data-streamer-out.cc (streamer_write_vrange): Same. * value-range.h (class vrange): Make streamer_write_vrange a friend. --- gcc/data-streamer-in.cc | 16 ++++++++++++---- gcc/data-streamer-out.cc | 17 ++++++++++++----- gcc/value-range.h | 1 + 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc index 07728bef413..578c328475f 100644 --- a/gcc/data-streamer-in.cc +++ b/gcc/data-streamer-in.cc @@ -248,14 +248,22 @@ streamer_read_value_range (class lto_input_block *ib, data_in *data_in, if (is_a (vr)) { frange &r = as_a (vr); - REAL_VALUE_TYPE lb, ub; - streamer_read_real_value (ib, &lb); - streamer_read_real_value (ib, &ub); + + // Stream in NAN bits. struct bitpack_d bp = streamer_read_bitpack (ib); bool pos_nan = (bool) bp_unpack_value (&bp, 1); bool neg_nan = (bool) bp_unpack_value (&bp, 1); nan_state nan (pos_nan, neg_nan); - r.set (type, lb, ub, nan); + + if (kind == VR_NAN) + r.set_nan (type, nan); + else + { + REAL_VALUE_TYPE lb, ub; + streamer_read_real_value (ib, &lb); + streamer_read_real_value (ib, &ub); + r.set (type, lb, ub, nan); + } return; } gcc_unreachable (); diff --git a/gcc/data-streamer-out.cc b/gcc/data-streamer-out.cc index afc9862062b..93dedfcb895 100644 --- a/gcc/data-streamer-out.cc +++ b/gcc/data-streamer-out.cc @@ -410,7 +410,7 @@ streamer_write_vrange (struct output_block *ob, const vrange &v) gcc_checking_assert (!v.undefined_p ()); // Write the common fields to all vranges. - value_range_kind kind = v.varying_p () ? VR_VARYING : VR_RANGE; + value_range_kind kind = v.m_kind; streamer_write_enum (ob->main_stream, value_range_kind, VR_LAST, kind); stream_write_tree (ob, v.type (), true); @@ -429,15 +429,22 @@ streamer_write_vrange (struct output_block *ob, const vrange &v) if (is_a (v)) { const frange &r = as_a (v); - REAL_VALUE_TYPE lb = r.lower_bound (); - REAL_VALUE_TYPE ub = r.upper_bound (); - streamer_write_real_value (ob, &lb); - streamer_write_real_value (ob, &ub); + + // Stream out NAN bits. bitpack_d bp = bitpack_create (ob->main_stream); nan_state nan = r.get_nan_state (); bp_pack_value (&bp, nan.pos_p (), 1); bp_pack_value (&bp, nan.neg_p (), 1); streamer_write_bitpack (&bp); + + // Stream out bounds. + if (kind != VR_NAN) + { + REAL_VALUE_TYPE lb = r.lower_bound (); + REAL_VALUE_TYPE ub = r.upper_bound (); + streamer_write_real_value (ob, &lb); + streamer_write_real_value (ob, &ub); + } return; } gcc_unreachable (); diff --git a/gcc/value-range.h b/gcc/value-range.h index 39023e7b5eb..2b4ebabe7c8 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -76,6 +76,7 @@ class GTY((user)) vrange { template friend bool is_a (vrange &); friend class Value_Range; + friend void streamer_write_vrange (struct output_block *, const vrange &); public: virtual void accept (const class vrange_visitor &v) const = 0; virtual void set (tree, tree, value_range_kind = VR_RANGE);