From patchwork Fri Oct 14 14:30:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1690057 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=2620:52:3:1:0:246e:9693:128c; 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=l892REKD; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4MppjQ2XHHz23jn for ; Sat, 15 Oct 2022 01:31:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C25DF3857423 for ; Fri, 14 Oct 2022 14:31:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C25DF3857423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665757877; bh=bjQK2X7r0d74JLw7bHwD0gzx6tXUMsBME3U8p788Esw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=l892REKDrfQ4UczNDPWVskGQJuraJ047MG/HS/OHRUeRf/+RErUi7GCKL1dEq8JwE 02OS0G6tKp1nLoU/NSNg+z/BBtg28diwWGsdzWZAWAPpB0TRX5qVL2wPWZBzMPAwj4 eUix4uvWPo2husLfDro80M03UpWiRMeD7PAnr1kE= 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 438A93858024 for ; Fri, 14 Oct 2022 14:30:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 438A93858024 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-247-sGUfhStbOemC5dEcphUQlQ-1; Fri, 14 Oct 2022 10:30:53 -0400 X-MC-Unique: sGUfhStbOemC5dEcphUQlQ-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 C6E00886461 for ; Fri, 14 Oct 2022 14:30:52 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.163]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D7BE4043479; Fri, 14 Oct 2022 14:30:52 +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 29EEUnrU672031 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 14 Oct 2022 16:30:49 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 29EEUnEk672030; Fri, 14 Oct 2022 16:30:49 +0200 To: Jakub Jelinek Subject: [PATCH] Check rvc_normal in real_isdenormal. Date: Fri, 14 Oct 2022 16:30:47 +0200 Message-Id: <20221014143047.672008-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.5 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 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 Cc: GCC patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" [Jakub, thanks for pointing this out. OK?] [-Inf, -Inf] is being flushed to [-Inf, -0.0] because real_isdenormal is being overly pessimistic. It is missing a check for rvc_normal. This doesn't cause problems in real.cc because all uses of real_isdenormal are already on the rvc_normal path. The uses in value-range.cc however, are not. This patch adds a check for rvc_normal. gcc/ChangeLog: * real.h (real_isdenormal): Check rvc_normal. * value-range.cc (range_tests_floats): New test. --- gcc/real.h | 2 +- gcc/value-range.cc | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/real.h b/gcc/real.h index f9528d765ec..306e9593866 100644 --- a/gcc/real.h +++ b/gcc/real.h @@ -290,7 +290,7 @@ extern bool real_issignaling_nan (const REAL_VALUE_TYPE *); inline bool real_isdenormal (const REAL_VALUE_TYPE *r) { - return (r->sig[SIGSZ-1] & SIG_MSB) == 0; + return r->cl == rvc_normal && (r->sig[SIGSZ-1] & SIG_MSB) == 0; } /* Determine whether a floating-point value X is finite. */ diff --git a/gcc/value-range.cc b/gcc/value-range.cc index 6b4f3dddcd5..ee15eb35df8 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -4014,6 +4014,11 @@ range_tests_floats () r1.clear_nan (); r0.intersect (r1); ASSERT_TRUE (r0.undefined_p ()); + + // Make sure [-Inf, -Inf] doesn't get normalized. + r0 = frange_float ("-Inf", "-Inf"); + ASSERT_TRUE (real_isinf (&r0.lower_bound (), true)); + ASSERT_TRUE (real_isinf (&r0.upper_bound (), true)); } void