From patchwork Sun Aug 2 10:01:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 1339892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nextmovesoftware.com header.i=@nextmovesoftware.com header.a=rsa-sha256 header.s=default header.b=aSY6kW/V; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BKGkd53Hnz9sRN for ; Sun, 2 Aug 2020 20:01:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1CDA7385DC14; Sun, 2 Aug 2020 10:01:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 1389A3858D35 for ; Sun, 2 Aug 2020 10:01:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1389A3858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=roger@nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lcMq9RHH945SVeX5jUrcwku8OUFHSxKdocVLx8hbz/o=; b=aSY6kW/VUsoDjer+S4b1asi/vZ W9NoYlb7Q1RnZtm2vChFRf7j1uwF3m/cPYCdgdxOztWo13UaGHytvp/jvcoYA0jzSQn8xfWGBkS7I L7xqrwxTJ/mNAd8QnIoC3pM5tzkeAe8Vq/tmO7hL2z0z01Ib2qU9Tesr/oDL5oW4uJA19d7IxeyJl cnP3JGi1QJx7iHn0YNSc70Mv+DjyLQ3jh7KHa+3PPYLF+13L8l1+nobMaSm0cMreqwwIweKS/6UaZ nvEINuM6SFa8bU5u8BcMh/m3uYDL3QshQD1ZT3ftxFZHmF1zOIH4zG87cV+VAjK32vCfRKv/Jad9k MY+2Q7Jw==; Received: from host86-137-89-56.range86-137.btcentralplus.com ([86.137.89.56]:62337 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1k2Anv-0007Pk-Gn for gcc-patches@gcc.gnu.org; Sun, 02 Aug 2020 06:01:19 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] PR rtl-optimization 61494: Preserve x-0.0 with HONOR_SNANS. Date: Sun, 2 Aug 2020 11:01:18 +0100 Message-ID: <002b01d668b3$de570d50$9b0527f0$@nextmovesoftware.com> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AdZosbl8OUuuBCFPT7KRtTlaesJVzA== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" The following patch avoids simplifying x-0.0 to x when -fsignaling-nans is specified, which resolves PR rtl-optimization 61494. Indeed, running the test program attached to that PR now reports no failures. Alas reducing that validation program to a portable test for the GCC testsuite is a challenge that I plan to leave to a volunteer. The fix itself is a trivial one-liner, so it's curious that the compiler has been broken for so long. Hopefully folks agree that correctness is more important than testability (but both are desirable). The following patch has been tested on x86_64-pc-linux-gnu with a "make bootstrap" and "make -k check" with no new regressions. Ok for mainline? 2020-08-02 Roger Sayle gcc/ChangeLog PR rtl-optimization/61494 * simplify-rtx.c (simplify_binary_operation_1) [MINUS]: Don't simplify x - 0.0 with -fsignaling-nans. Thanks in advance, Roger --- Roger Sayle NextMove Software Cambridge, UK diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index d221168..a9d8e8c 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -2678,11 +2678,12 @@ simplify_binary_operation_1 (enum rtx_code code, machine_mode mode, && !contains_symbolic_reference_p (op1)) return simplify_gen_unary (NOT, mode, op1, mode); - /* Subtracting 0 has no effect unless the mode has signed zeros - and supports rounding towards -infinity. In such a case, - 0 - 0 is -0. */ + /* Subtracting 0 has no effect unless the mode has signalling NaNs, + or has signed zeros and supports rounding towards -infinity. + In such a case, 0 - 0 is -0. */ if (!(HONOR_SIGNED_ZEROS (mode) && HONOR_SIGN_DEPENDENT_ROUNDING (mode)) + && !HONOR_SNANS (mode) && trueop1 == CONST0_RTX (mode)) return op0;