From patchwork Mon Sep 5 20:14:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1002 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp331527wrt; Mon, 5 Sep 2022 13:15:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR620++h5JvKNs9A+66XpYxfQdj51fR/jsgpD/NmKJATdxpiK+aEALwTwNRsoJkGvponAcqj X-Received: by 2002:a17:907:d8d:b0:741:4d1a:5954 with SMTP id go13-20020a1709070d8d00b007414d1a5954mr30252630ejc.307.1662408922744; Mon, 05 Sep 2022 13:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662408922; cv=none; d=google.com; s=arc-20160816; b=CtUMavRzcGlgExmB/Xs+Ln8xuS7gW7Ctnb2fFcPxRbVn903WCJi3H77g0c/2FLIhgb G2tofxBk52ObFvVZwHfY3c4hdxvX8uqcR0YU4lYNAnRu6DXv6z0FcBPdh1MVN3eZAxml lp+qmmuAgLU5YDVt0dYlZxWGOKpaI3QLj/rdh+GCbVK4h7sFtR+6LCHrDIeMI0Sm2xdn StFDaQg3OGW0ecEhS2LTYPbBy8hW/H+yQWwEiPFjvFAJ3Zeo9hVoz7N89Cd0LnXbSk9F ZqxJk+AismZ5bevvfxAovqCD2IOmupRTvbeNEyi2H/F9kwfGQ/dSsisBawVZe/CL35uN 5egw== 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=Ps0E/QuMo+Do31ciqHeauVDOOYW1GGwO7c/DrllbKFw=; b=ZyO2dIWFGAwdXapA1E40WZB1lgtdtn0UDIW+6EMqwVx368AdLxU/A1aXqmWKTFE5eh DFUVkeMba9HXBTWd6hD4fjTwo791POYzQJ+p/PDHf+FO4cLQ7GcIg/AwuT7RF1wQUkBR O+zbzoEt1JCDRIbqmR1AJPhZe+OaJJzWCTmhMB5Oupzf8sRBjuw/h6wVS3r2SjvOpHd8 6GkBZCtoevfoMuG3RjZ8kuH527nLvqR928Umg78lXGH9h6MVnomF27ymDOzwTbkytpwV sF/yI4t7AkwQGJf+vzHWuU5QU44V5BBP0HAaiWuSf211zBXXzmVqFsS/Bz0TRIZWSJW2 XvPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nJA2NnxZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id 9-20020a170906328900b0073dd243ae3bsi7422665ejw.505.2022.09.05.13.15.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 13:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nJA2NnxZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 AF78B385696A for ; Mon, 5 Sep 2022 20:15:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF78B385696A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662408921; bh=Ps0E/QuMo+Do31ciqHeauVDOOYW1GGwO7c/DrllbKFw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=nJA2NnxZXJlcpuM38eccHVC3R8xQfYtq2HItHay253e1feJniiEy2nZjgFtYPT9qv 0oPAzI+IXNFg/0XSPGDYpom8iBiUOVFIU3toHPU/9WShyjyC/dTMjnE9BtHnm8kN4s JoN7paBa+yp/fA1rTHdOAqeyiSwionRAWL68O0B8= 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 A63CC3858D28 for ; Mon, 5 Sep 2022 20:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A63CC3858D28 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-387-EyXpRe3qPyGI5PK1PU50bQ-1; Mon, 05 Sep 2022 16:14:36 -0400 X-MC-Unique: EyXpRe3qPyGI5PK1PU50bQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADA82811E80 for ; Mon, 5 Sep 2022 20:14:35 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4AD66403344; Mon, 5 Sep 2022 20:14:35 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.17.1/8.17.1) with ESMTPS id 285KEVKs3447997 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Sep 2022 22:14:31 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 285KEVn23447995; Mon, 5 Sep 2022 22:14:31 +0200 To: GCC patches Subject: [COMMITTED] Do not fold __builtin_signbit if NAN is a possibility. Date: Mon, 5 Sep 2022 22:14:12 +0200 Message-Id: <20220905201412.3447974-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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?1743162098542422407?= X-GMAIL-MSGID: =?utf-8?q?1743162098542422407?= I had some queued up work to try harder to keep the sign bit up to date in the presence of NANs, but after the discussion with Richi regarding the representation of NAN and signs in the frange, I've decided to put it aside until after Cauldron, since it'll probably get rewritten anyhow. So for now, the sign property in the frange is not applicable to NANs. Right now the only user of the sign bit that affects generated code (apart from signed zeros) is __builtin_sign, so I'm just checking for NAN there. Signed zeros continue working as before. Regstrapped and mpfr checked on x86-64 Linux. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_builtin_int_call): Ignore sign bit when there's the possibility of a NAN. --- gcc/gimple-range-fold.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 3543f0980b8..c9c7a2ccc70 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1029,7 +1029,9 @@ fold_using_range::range_of_builtin_int_call (irange &r, gcall *call, frange tmp; if (src.get_operand (tmp, arg)) { - if (tmp.get_signbit ().varying_p ()) + if (tmp.get_signbit ().varying_p () + // FIXME: We don't support signed NANs yet. + || !tmp.get_nan ().no_p ()) return false; if (tmp.get_signbit ().yes_p ()) r.set_nonzero (type);