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.133.124]) by sourceware.org (Postfix) with ESMTPS id 4B9E33858439 for ; Mon, 10 Oct 2022 12:50:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B9E33858439 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=1665406200; 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=aogFejXMYSrEZq18qurQsaBFx+KmXEKgShlIpSILXLk=; b=VKvoc9hdElMRJ0IHCUyEOvfvRu0u1H04i1ULhbgskxX0y/HEGhl+/F16xUQ1GSEW70ENyf n93W2ZKq8HrAzXIzIyhodmRieaDNrH5uXf1zOwob0U1sd6fJ+q1bVnpFpuDzHjJxSamzQd RafrVVVK/muPDFdLebWrdg1QntAwCo8= 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-618-nKZ9BC-9OlmYiRzTS2fbIQ-1; Mon, 10 Oct 2022 08:49:56 -0400 X-MC-Unique: nKZ9BC-9OlmYiRzTS2fbIQ-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 4246C3C3C960 for ; Mon, 10 Oct 2022 12:49:56 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C50FD2083A19; Mon, 10 Oct 2022 12:49: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 29ACnrux154186 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 10 Oct 2022 14:49:54 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29ACnr4T154185; Mon, 10 Oct 2022 14:49:53 +0200 From: Aldy Hernandez To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Add frange::maybe_isnan (bool sign). Date: Mon, 10 Oct 2022 14:49:45 +0200 Message-Id: <20221010124946.154152-4-aldyh@redhat.com> In-Reply-To: <20221010124946.154152-1-aldyh@redhat.com> References: <20221010124946.154152-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 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: It is useful to know if there's the possiblity of a NAN with a given sign. This is to complement maybe_isnan(void) which returns TRUE for a NAN of any sign. A follow-up patch implementing ABS will make use of this. gcc/ChangeLog: * value-range.h (frange::maybe_isnan): New. --- gcc/value-range.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gcc/value-range.h b/gcc/value-range.h index 484f911bd90..07a2067898c 100644 --- a/gcc/value-range.h +++ b/gcc/value-range.h @@ -323,6 +323,7 @@ public: bool known_isnan () const; bool known_isinf () const; bool maybe_isnan () const; + bool maybe_isnan (bool sign) const; bool maybe_isinf () const; bool signbit_p (bool &signbit) const; private: @@ -1295,6 +1296,18 @@ frange::maybe_isnan () const return m_pos_nan || m_neg_nan; } +// Return TRUE if range is possibly a NAN with SIGN. + +inline bool +frange::maybe_isnan (bool sign) const +{ + if (undefined_p ()) + return false; + if (sign) + return m_neg_nan; + return m_pos_nan; +} + // Return TRUE if range is a +NAN or -NAN. inline bool -- 2.37.3