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 85A053858CDA for ; Tue, 28 Mar 2023 08:16:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85A053858CDA 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=1679991401; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=SAHFk+k0zD2qgP2g8UEVb36g25NopoGcAI0i7sc6H48=; b=P6CqZmYAZr5CfOtE8qDexAsNW0QLGepIv8BXbrYaTPyv8EPQLUKQnyX7K55B/Ws/gpQf7u OWBEm/JTaW3lOkJjOdbNW+59DxhVC4tnOxhSundPmyJIIfPnXps7V/jNIhtrzP4FGbqW6l C7lj9I/qHDukSj74E6J7jTcY9IPBekI= 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 From: Jakub Jelinek 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: Reply-To: Jakub Jelinek 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-Type: text/plain; charset=us-ascii 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 List-Id: 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. --- 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; } Jakub