From patchwork Sun Aug 2 10:00:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Sayle X-Patchwork-Id: 1339891 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=Cj2MvokC; 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 4BKGkY0T97z9sRN for ; Sun, 2 Aug 2020 20:01:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A726C3857C6E; Sun, 2 Aug 2020 10:01:20 +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 3FD3D3858D35 for ; Sun, 2 Aug 2020 10:01:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3FD3D3858D35 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=wvrtfI1H57rhm0F/LhZQ7KkiZSTaSTJMxrNHjON0tZg=; b=Cj2MvokCnPcD5niGlhtixrwaMy Qdk+F8BV5Ox+bdIqGwzG+auu/tMWvaYT8Hr2zwBOV9Mwn93pVcHBB38NZ5Ppn71vsuIrjhVYe6mDZ RYD1RTl9v398LY60ZyzgxJo6GapgofHexcRZP7azKISaQHqjJRvp8UQsCyxk0XxGOxbWtQRnU6qzc 78gL3Mq6wZ7mdsrkBThkUiWtSNKqI/FfyTxMLju6uvrl+tdLNeC8UhZVep5ENsY5Rs/N/m/f4dQ8v g/Vy+MyBouOkcfbenPila8HubCdxi6WFj321vcr6tr0l9ppI75JRE4uE1kDuFMSOfQuXQ4TiU49eR W56r6/vg==; 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 1k2Amu-0007Pk-QN for gcc-patches@gcc.gnu.org; Sun, 02 Aug 2020 06:01:17 -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:00:15 +0100 Message-ID: <002001d668b3$b8f7ca90$2ae75fb0$@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;