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: 66988 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A0D333858C50 for ; Tue, 28 Mar 2023 08:17:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0D333858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679991431; 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=vn+vp6qW/SS2ojKkaGtFndzzWeTtbukjDW5S8Jzx+4A2dl1JxqLlZ1PBayK5DUGkz BdqiHIaJVlFmp15sgOCFl9jH86jEcg+VTE55qCEN+QLzFCUxFJp0AqW5KACPThsx9s 8L4gvzNKyTXuq6Sh+J04+JotctMHromvQ76BBjt4= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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; }