From patchwork Fri Aug 26 15:46:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp292995wro; Fri, 26 Aug 2022 08:47:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR620AJmr+XknMXKff2lxBipQd+rEQM61me/luNZuq/WXPPMLtLjHOUP0AU5eM1GOZ3OF+ZT X-Received: by 2002:a17:907:3ea1:b0:73e:6881:d189 with SMTP id hs33-20020a1709073ea100b0073e6881d189mr2657374ejc.726.1661528820056; Fri, 26 Aug 2022 08:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661528820; cv=none; d=google.com; s=arc-20160816; b=dS6+uOy/y/kmv0mF7twVSVtblxEyFQ6poOLyiWwAloCo/niJtf9ETiXp20iXTElNOs 8Tle6sZlA+KogjqlVXok7unIhFPpAMzCylNqTBiKLJ4tUX6cZ1lO8bfg4km84KHab2AR HWYiC+2j91JzinSgIpSSm8DrgtL7W/niXtnhjI+2Q0SG34//9ZIl1GISigjbmZ3M6lU0 49XTWXqiD9FQW9RC9ZthZc6hDASC4HOhBeKhMMVmbNmR/BiJu1AEY4KXYUbkEPDDsdb/ xMD0Y1MCrq8yIe+Cr6lme3X2d+IYnFQuTjmnZ+SFtRR8OyGE6MqWLS361hlsmflypGIG aXOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=pIU3bIkwakiAnsGmQIOzm5eGtldqLV+zmgxbQDLTF2o=; b=agKjxplhHBxBTv2SQmcX2KJT8jlL0h4B1eWdc2bhJX3agFsIBSz6SZLTeVwBGjqrHZ 5zx7vYmcZPnGhnAXSLohNFiMqaLqAlCsmX/GIVL5Um6NmvETpT+PJ46uLcs/1Jl4cBMd 8rO+TkqsTTMYFURVNbMHW5BxSUNabxxM1LQftzgduS5wRhvijZdM6PmHxDiEjMI9jdqZ i9ZgkKIEcEzKOPVXZFQwBdU7WWqo7wJwLeEUtF/7j2KaZ+W8+7zptDoARmLzyDgb3nPl h1neypQJKkuUv6Fk7dkYoTcQ/27B8dtPuxwBYp0vbGxx5dcK3Q9FYv6zES/URUP9CVlY XcqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CX2BhgEY; 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 p34-20020a056402502200b00445d2524d42si1707153eda.493.2022.08.26.08.46.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 08:47:00 -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=CX2BhgEY; 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 996A03851155 for ; Fri, 26 Aug 2022 15:46:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 996A03851155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1661528817; bh=pIU3bIkwakiAnsGmQIOzm5eGtldqLV+zmgxbQDLTF2o=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CX2BhgEYjDzkCzWJbPAj5OLOIcvUdxQLcGCJJYkU3b7+bvp24Vva0pq+S/PdPGcf3 WWP8p+qxt2mER7YjAmKoQ1k/c0FowGHAPK6FZspvxmFiSFunrcgjM0BDQ1y4cFPHwx SvOky89RaEUnZqybmzKq0Ehp5Eiou/DoC/YBTqHc= 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 9300B38515D9 for ; Fri, 26 Aug 2022 15:46:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9300B38515D9 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-277-PoxYMMGGOMaAx15frkSNHA-1; Fri, 26 Aug 2022 11:46:13 -0400 X-MC-Unique: PoxYMMGGOMaAx15frkSNHA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B5782185A794 for ; Fri, 26 Aug 2022 15:46:12 +0000 (UTC) Received: from abulafia.home (unknown [10.39.193.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67383C15BB3; Fri, 26 Aug 2022 15:46:12 +0000 (UTC) Received: from abulafia.home (localhost [127.0.0.1]) by abulafia.home (8.17.1/8.17.1) with ESMTPS id 27QFk9PX1155995 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 26 Aug 2022 17:46:09 +0200 Received: (from aldyh@localhost) by abulafia.home (8.17.1/8.17.1/Submit) id 27QFk9DZ1155994; Fri, 26 Aug 2022 17:46:09 +0200 To: GCC patches Subject: [PATCH] [ranger] x == -0.0 does not mean we can replace x with -0.0 Date: Fri, 26 Aug 2022 17:46:06 +0200 Message-Id: <20220826154606.1155977-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Aldy Hernandez via Gcc-patches From: Aldy Hernandez Reply-To: Aldy Hernandez Cc: Jakub Jelinek 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?1742239244148615005?= X-GMAIL-MSGID: =?utf-8?q?1742239244148615005?= On the true side of x == -0.0, we can't just blindly value propagate the -0.0 into every use of x because x could be +0.0 (or vice versa). With this change, we only allow the transformation if !HONOR_SIGNED_ZEROS or if the range is known not to contain 0. Will commit after tests complete. gcc/ChangeLog: * range-op-float.cc (foperator_equal::op1_range): Do not blindly copy op2 range when honoring signed zeros. --- gcc/range-op-float.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc index ad2fae578d2..ff9fe312acf 100644 --- a/gcc/range-op-float.cc +++ b/gcc/range-op-float.cc @@ -252,8 +252,21 @@ foperator_equal::op1_range (frange &r, tree type, switch (get_bool_state (r, lhs, type)) { case BRS_TRUE: - // If it's true, the result is the same as OP2. - r = op2; + if (HONOR_SIGNED_ZEROS (type) + && op2.contains_p (build_zero_cst (type))) + { + // With signed zeros, x == -0.0 does not mean we can replace + // x with -0.0, because x may be either +0.0 or -0.0. + r.set_varying (type); + } + else + { + // If it's true, the result is the same as OP2. + // + // If the range does not actually contain zeros, this should + // always be OK. + r = op2; + } // The TRUE side of op1 == op2 implies op1 is !NAN. r.set_nan (fp_prop::NO); break;