From patchwork Tue Mar 28 08:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 75891 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2051312vqo; Tue, 28 Mar 2023 01:17:39 -0700 (PDT) X-Google-Smtp-Source: AKy350b0r2qI0I1OkEfZKz6IxFs6TzElPxzHLR4LYP4vPyEejsgBSSIUxLVsaobNBOkvDGfjXiRi X-Received: by 2002:a17:906:4d8e:b0:932:35b1:47fa with SMTP id s14-20020a1709064d8e00b0093235b147famr14991950eju.64.1679991459477; Tue, 28 Mar 2023 01:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679991459; cv=none; d=google.com; s=arc-20160816; b=swYXkiIZN9H7fbEMnmPTvYPGXTil+1bwoequrOB5k51lYzP1AdfoolMf+Iv0Yk4D5/ eQF7kG5qq6fRC3f2HTV+RYV+jxnaHnKT4Ph7c8HIWpus7VXBZPLGK41j3msFfOALvwS+ 5Sx50oO2dQU3YrKwaZapIR1a4uCPdpadkc9AkMe6viWWOTGMsi2rCo9yavqlmaAxEfXn XdV6gQUcIUFN8jzHuGrWwmconw/g4AgSWgUJE0J3RbhUKKtuvprsokecDUn4fBp+Zuxg 6p7m4kh4J9CMaJzgmTOBq5I7oDRMxg4nveOAHMMt/UJgaVSOGUjTPQUDwFARGmRJ7FP9 /x0Q== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=SAHFk+k0zD2qgP2g8UEVb36g25NopoGcAI0i7sc6H48=; b=wRbT5/4fMazGAoFADcff/mh+v/d7xBNqHpB81D/Eld6Ml/4igOfigoHlALWTtP25K0 Z3wLl+viFD84O0Ch2tdEQSok9gScps54PAVydKHv+CjDq6z8/38YQrqeuVir6xKGuOrk 6dnvQ9wsU5ScCgh4tn+4j0pJ5k+RGMHXsYCrAWKlwbRZpqXqOtOPWXH+35aMTWvGv3pO X1X9qDLXOw5Bsd5Vg72uMnJr00ghDZ0NeLu+TBq7Zp4loOB8uPVUVY6TLUow2sffYLNY yr+HxPXBnkSjPmeIXX7P70Q8g1htHpV81mVRDFhd4DC5Hiq+1DczA/gsxZGECc4ziytO Rjag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QvZiBJ5r; 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 w26-20020a170906131a00b00946b646c08fsi1180797ejb.907.2023.03.28.01.17.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 01:17:39 -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=QvZiBJ5r; 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 D089B3858298 for ; Tue, 28 Mar 2023 08:17:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D089B3858298 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679991448; bh=SAHFk+k0zD2qgP2g8UEVb36g25NopoGcAI0i7sc6H48=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=QvZiBJ5rpa8Fc6LAbYRRX2JzKgYNI4JeOliNySJUanMkkHrM69oOMTnS7obmjatwH 0y7XxA8nQ1vWtHpHTQM4Ccoq0VoeMKoadKUY5O/aVSWigVeANYMtNv6H2SV1jK4q5p E9J6YHfBw/Zb40kMBTm20BeI+IECK+5C6tFzUyUI= 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 85A053858CDA for ; Tue, 28 Mar 2023 08:16:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85A053858CDA 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-533-YyfjbSU3OhayYYZGkzNYEw-1; Tue, 28 Mar 2023 04:16:39 -0400 X-MC-Unique: YyfjbSU3OhayYYZGkzNYEw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B7CD101A550 for ; Tue, 28 Mar 2023 08:16:39 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4061F440BC; Tue, 28 Mar 2023 08:16:39 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32S8GaP91442059 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 28 Mar 2023 10:16:37 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32S8Gavb1442056; Tue, 28 Mar 2023 10:16:36 +0200 Date: Tue, 28 Mar 2023 10:16:36 +0200 To: Aldy Hernandez , Andrew MacLeod Cc: gcc-patches@gcc.gnu.org Subject: [RFC PATCH] range-op-float: Only flush_denormals_to_zero for +-*/ [PR109154] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1761598724832706953?= X-GMAIL-MSGID: =?utf-8?q?1761598724832706953?= Hi! As discussed in the PR, flushing denormals to zero on every frange::set might be harmful for e.g. x < 0.0 comparisons, because we then on both sides use ranges that include zero [-Inf, -0.0] on the true side, and [-0.0, +Inf] NAN on the false side, rather than [-Inf, nextafter (-0.0, -Inf)] on the true side. The following patch does it only in range_operator_float::fold_range which is right now used for +-*/ (both normal and reverse ops of those). Though, I don't see any difference on the testcase in the PR, but not sure what I should be looking at and the reduced testcase there has undefined behavior. Anyway, bootstrapped/regtested on x86_64-linux and i686-linux. If it doesn't help with the PR, could be as well deferred for stage 1. 2023-03-28 Jakub Jelinek PR tree-optimization/109154 * value-range.h (frange::flush_denormals_to_zero): Make it public rather than private. * value-range.cc (frange::set): Don't call flush_denormals_to_zero here. * range-op-float.cc (range_operator_float::fold_range): Call flush_denormals_to_zero. Jakub --- gcc/value-range.h.jj 2023-03-23 15:25:47.059741131 +0100 +++ gcc/value-range.h 2023-03-27 18:56:35.164190929 +0200 @@ -373,6 +373,7 @@ public: void update_nan (tree) = delete; // Disallow silent conversion to bool. void update_nan (const nan_state &); void clear_nan (); + void flush_denormals_to_zero (); // fpclassify like API bool known_isfinite () const; @@ -389,7 +390,6 @@ private: bool union_nans (const frange &); bool intersect_nans (const frange &); bool combine_zeros (const frange &, bool union_p); - void flush_denormals_to_zero (); tree m_type; REAL_VALUE_TYPE m_min; --- gcc/value-range.cc.jj 2023-03-27 12:50:45.876826415 +0200 +++ gcc/value-range.cc 2023-03-27 18:45:50.127495492 +0200 @@ -361,8 +361,6 @@ frange::set (tree type, normalize_kind (); - flush_denormals_to_zero (); - if (flag_checking) verify_range (); } --- gcc/range-op-float.cc.jj 2023-03-27 13:28:18.847264635 +0200 +++ gcc/range-op-float.cc 2023-03-27 18:50:24.498537727 +0200 @@ -112,6 +112,8 @@ range_operator_float::fold_range (frange } } + r.flush_denormals_to_zero (); + return true; }