From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 8FAD3385B839 for ; Wed, 12 Oct 2022 06:50:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8FAD3385B839 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665557458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zec7Pw9ccaVlFzYyjy0MjTvpZdsbY7L9y0g/5haonv0=; b=MaYVtcLSrBIxAlCeDmPfdwzeYWr18ikCgSN7cq/d6CEIk+bzrTMgNi8yqB46WqsjhxksWl HlOId23ky5cwyrXOBERh1GnoxEZvADK+2fBusgr19Tf6nAqIy1rjvAwy9b08pggKKj2kBc 7IeNGu2fIOiXdIAEDgvX11JGWxxOjMg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-y9J7ADPXOM-wd_PTnAHzsg-1; Wed, 12 Oct 2022 02:50:56 -0400 X-MC-Unique: y9J7ADPXOM-wd_PTnAHzsg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C0E31C051A3 for ; Wed, 12 Oct 2022 06:50:56 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25CF52166B2F; Wed, 12 Oct 2022 06:50:55 +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 29C6ostI412954 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 12 Oct 2022 08:50:54 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29C6osct412953; Wed, 12 Oct 2022 08:50:54 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Add method to query the sign of a NAN. Date: Wed, 12 Oct 2022 08:50:49 +0200 Message-Id: <20221012065050.412900-4-aldyh@redhat.com> In-Reply-To: <20221012065050.412900-1-aldyh@redhat.com> References: <20221012065050.412900-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.0 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,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 List-Id: In writing some range-op entries I noticed we don't have a way to query the sign of the NAN in a range, unless the range only contains NAN, in which case you can just use frange::signbit_p. This patch adds a method that returns TRUE if there exists the possiblity of a NAN and we know its sign. gcc/ChangeLog: * value-range.h (frange::nan_signbit_p): New. --- gcc/value-range.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/value-range.h b/gcc/value-range.h index cb5e9d0522c..60b989b2b50 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -328,6 +328,7 @@ public: bool maybe_isnan (bool sign) const; bool maybe_isinf () const; bool signbit_p (bool &signbit) const; + bool nan_signbit_p (bool &signbit) const; private: void verify_range (); bool normalize_kind (); @@ -1358,4 +1359,20 @@ frange::signbit_p (bool &signbit) const return false; } +// If range has a NAN with a known sign, set it in SIGNBIT and return +// TRUE. + +inline bool +frange::nan_signbit_p (bool &signbit) const +{ + if (undefined_p ()) + return false; + + if (m_pos_nan == m_neg_nan) + return false; + + signbit = m_neg_nan; + return true; +} + #endif // GCC_VALUE_RANGE_H -- 2.37.3