From patchwork Mon Jun 19 10:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Toru Kisuki X-Patchwork-Id: 109903 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2898714vqr; Mon, 19 Jun 2023 03:33:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qEqdYw4Q0Pu62qUNILW6kyGLteyCIX6mgp5AAvrTiToGuZWenGmpZegHSrioSQCFPNTcp X-Received: by 2002:a17:907:1ca8:b0:973:d076:67ab with SMTP id nb40-20020a1709071ca800b00973d07667abmr8742203ejc.42.1687170818673; Mon, 19 Jun 2023 03:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687170818; cv=none; d=google.com; s=arc-20160816; b=UWDJBllvo3o3+RrfFFCepsgDFqYkU0KwfRbUrI7IMtst14QSNLiqh/mVrlkEuIhk06 EHCZVcKk/Dn13T+OmvM7xFvxSrWpHIzAg2LugNfgYYC04Yd4UFdQcrhkfp14JbRbehBI 9gqo5wtS6v/tB54YgTXLMjnwd9A3s61HOMNtyOcgLUCJ4yUpPlN8+XuT2dYglGD9TCNI DykNcGfhRu+DuiNXntlw+BcmJugPePBLOyQxW1oOQzMa1QM0oi2b8yG6vF947ZnV63PY 3CH1urjieBEapggEgpCrL7TzG2523gjrHy7zNGMJjptdlbm6HaH+WwYcsEBBZytWqBcv jn7Q== 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-transfer-encoding:mime-version:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=an4PO3i4uMztE5Aj6tsgeYTAWoWf229eubQuxx5Fq00=; b=q9bqoDM0XsShcxnXx2rd6ccGPd/HUdyV/PprbBEpdL1CgY11TxLOwG5SqTe32MjroQ f+8e6B29OnzPrGiXaQM9CokmUIBHqR/13ps/KoTMPNXYJ2Bzibb+KlUbtdTUSE0j87jl wAK80dvSOHXK0GliF9NutrzznlLEKKkmV5iRCW8yu2YWcImLls/2OqKA84aSRDi7p5ZL iMGe1yVTkVOIycuqLyPUj0soBP3tqUBqtX+SEfXGm9+ko9dhCi3yTy/qC/XUHP2BNdrF BNKIMVsKsHvPa759ON+JsCsBD0OpszM1LusyH2m0m7bxUCfwa9xArDp5Q2Y09fs8UU/N eq6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=y1kicfzJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id b14-20020a1709062b4e00b00988a4c7313fsi942635ejg.269.2023.06.19.03.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 03:33:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=y1kicfzJ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 566E13858D32 for ; Mon, 19 Jun 2023 10:33:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 566E13858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687170817; bh=an4PO3i4uMztE5Aj6tsgeYTAWoWf229eubQuxx5Fq00=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=y1kicfzJjZ8nyCyoHvx7s6tRzhTtfhRVkRZoirmbKBbyXYUu2MJJk/W1eVgNwNn5b MaQay6QmPmC1sKn5jrj0wA6e/nTlW199BaYmxqsNo3FGrJ8Ye1JqqLH+qTGzbPqVuV KiTH+y8M/DgevUdncxw+72vfnlvMfcccyutglgCY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mxa.tachyum.com (mxa.tachyum.com [50.229.46.153]) by sourceware.org (Postfix) with ESMTPS id C1F383858D28 for ; Mon, 19 Jun 2023 10:32:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C1F383858D28 X-Virus-Scanned: by SpamTitan at tachyum.com To: "gcc-patches@gcc.gnu.org" Subject: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans Thread-Topic: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans Thread-Index: AQHZophl7DQKZR/MWEOjFmoa954OUw== Date: Mon, 19 Jun 2023 10:32:41 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, T_STY_INVIS_DIRECT 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Toru Kisuki via Gcc-patches From: Toru Kisuki Reply-To: Toru Kisuki 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?1769126828749673842?= X-GMAIL-MSGID: =?utf-8?q?1769126828749673842?= Hi, With -O3 -fsignaling-nans -fno-signed-zeros, compiler should not simplify 'x + 0.0' to 'x'. GCC Bugzilla : Bug 110305 gcc/ChangeLog: 2023-06-19 Toru Kisuki * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): --- gcc/simplify-rtx.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.38.1 diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index e152918b0f1..cc96b36ad4e 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -2698,7 +2698,8 @@ simplify_context::simplify_binary_operation_1 (rtx_code code, when x is NaN, infinite, or finite and nonzero. They aren't when x is -0 and the rounding mode is not towards -infinity, since (-0) + 0 is then 0. */ - if (!HONOR_SIGNED_ZEROS (mode) && trueop1 == CONST0_RTX (mode)) + if (!HONOR_SIGNED_ZEROS (mode) && !HONOR_SNANS (mode) + && trueop1 == CONST0_RTX (mode)) return op0; /* ((-a) + b) -> (b - a) and similarly for (a + (-b)). These