[COMMITTED] frange::set_signbit: Avoid changing sign when already in the correct sign.
Message ID | 20220912130711.484083-1-aldyh@redhat.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1872152wrt; Mon, 12 Sep 2022 06:08:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Vf/5XpVsKNgK17GJaLVCBJl1QHKYLJrZlHBM3LybpBKCC2FtQaBtH9pd4mESNhpVbLcim X-Received: by 2002:aa7:df8b:0:b0:44e:882f:7c5c with SMTP id b11-20020aa7df8b000000b0044e882f7c5cmr21923298edy.418.1662988113046; Mon, 12 Sep 2022 06:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662988113; cv=none; d=google.com; s=arc-20160816; b=0LcVW6RCtLnj/hgh0xXwLoUihNQkuiwHff8+y774DYfwF+gOnFtOdso1/s2E+OlB0y 7Zz/YSQyiJ7dp0tcs7ywYqxmQo9ZAZfXqtWG8gBLJ68wMw7TjmHtViE9jO15RivS+ee6 SnpkI5DxSjie3va0VCorAtCPF0wRGKeqFWIwSJY2MS/hQ+J0QdGUYWfkZ1hf7dJjiNNG A4h06945ZT2vgp92pO/8bDOV2/SWGJJ5HXWiBA3XWH6CmFSc/Ju06QqithbD+GThi21N VGJ0DiC5aUSYPb03ukQzTtF6/YkIMmC44s7mqNDjihxMC0IzDFx7hqnT9q7LJ8EPqDkz L/aQ== 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:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=Ke2+VToL0UPXhejMKBJJrdUn7LkvdEhWa/UDffB5OdU=; b=vV5fNqjPWwn7RYF9iExYLd4BDCzw+EkdhRJre46qutZBzB6shda4DXpOphuN3wGwE3 8TXxIE/YsLBnIQG5IEbhQuCbmCht/cx4fptFV0kZpjkzra+DBUmopZJ3TnbDxS5hKOxs hXXnd6cRtHhyyUPK10rDpoPTm+7FI8l7uTn6Tx1YwIzalJW33wqPb449nE/IgSgJkjGL ryIRpx2K8TaVFS6T/vl+dYlEzhHXfQRLQfpQbt/0kg/N2oeKrrZcb3ITx0bCgRlc/vok 4niY5LF/cGTWfvm2+oMZDkUik9eZ603OQW5esuKp88ASQ79pqeKMJ/FhATUVM6Uxuxpx oKMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="oLlQv1d/"; 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 v18-20020a056402349200b0044f29652bcbsi7974819edc.533.2022.09.12.06.08.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 06:08:33 -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="oLlQv1d/"; 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 98DE93856947 for <ouuuleilei@gmail.com>; Mon, 12 Sep 2022 13:08:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98DE93856947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662988111; bh=Ke2+VToL0UPXhejMKBJJrdUn7LkvdEhWa/UDffB5OdU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=oLlQv1d/aKiAENtrdigdjC57p+WHqtusIPFseOEW1uYCNbxGiCN2V8sNclUndUbIQ AGIPnyHnljWQo8eVHb6pKUGXry/64W6i0kVuzjV8oTcSDpmtyxlmZ1ssNUnDtbJp4Y SlwOBVGTs5Zj+5ErSiOSRQvHI55vHIqXEw/Ix+nY= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 4A5453856DD6 for <gcc-patches@gcc.gnu.org>; Mon, 12 Sep 2022 13:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4A5453856DD6 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-216-RW9pV3ieNY6y3j5mTCUcsQ-1; Mon, 12 Sep 2022 09:07:36 -0400 X-MC-Unique: RW9pV3ieNY6y3j5mTCUcsQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FF66101AA64 for <gcc-patches@gcc.gnu.org>; Mon, 12 Sep 2022 13:07:36 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.80]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B60B140EBF3; Mon, 12 Sep 2022 13:07:36 +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 28CD7X9L484138 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 12 Sep 2022 15:07:33 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28CD7XWO484137; Mon, 12 Sep 2022 15:07:33 +0200 To: GCC patches <gcc-patches@gcc.gnu.org> Subject: [COMMITTED] frange::set_signbit: Avoid changing sign when already in the correct sign. Date: Mon, 12 Sep 2022 15:07:12 +0200 Message-Id: <20220912130711.484083-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Aldy Hernandez <aldyh@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743769423920262754?= X-GMAIL-MSGID: =?utf-8?q?1743769423920262754?= |
Series |
[COMMITTED] frange::set_signbit: Avoid changing sign when already in the correct sign.
|
|
Commit Message
Aldy Hernandez
Sept. 12, 2022, 1:07 p.m. UTC
We should avoid pessimizing the signbit when it's already correct. In this particular case we were trying to change the signbit to "unknown", when it was obviously negative. This test is actually slated for removal with my upcoming revamp of the signbit and NAN tracking, per the conversations regarding tristate. The signbit will be removed in favor of keeping track of it in the range itself, and NAN will just be a pair of boolean flags. However, I don't plan to disturb the tree until after Cauldron. Tested on x86-64 Linux including mpfr tests. Also tested selftests with -ffinite-math-only on x86-64 as well as on a cross to pdp11-aout. gcc/ChangeLog: * value-range.cc (frange::set_signbit): Avoid changing sign when already in the correct sign. --- gcc/value-range.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/value-range.cc b/gcc/value-range.cc index adcaaa2a69a..6f0609959b3 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -316,9 +316,13 @@ frange::set_signbit (fp_prop::kind k) // Ignore sign changes when they're set correctly. if (!maybe_nan ()) { - if (real_less (&m_max, &dconst0)) + // It's negative and we're trying to make it negative or varying. + if (real_less (&m_max, &dconst0) && (k == fp_prop::YES + || k == fp_prop::VARYING)) return; - if (real_less (&dconst0, &m_min)) + // It's positive and we're trying to make it positive or varying. + if (real_less (&dconst0, &m_min) && (k == fp_prop::NO + || k == fp_prop::VARYING)) return; } // Adjust the range depending on the sign bit.