Message ID | 20220905134701.3330685-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 h4csp186128wrt; Mon, 5 Sep 2022 06:48:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR4gJX5sLwGohtoS7GQ5jESz1l5RCnoBggQF3ACCux7ReC7IIhWCXHk1k/H1buwvY8lR+Ieb X-Received: by 2002:a17:907:2e0b:b0:730:8aee:d674 with SMTP id ig11-20020a1709072e0b00b007308aeed674mr37515988ejc.104.1662385685624; Mon, 05 Sep 2022 06:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662385685; cv=none; d=google.com; s=arc-20160816; b=joSSylYrj7xjpAYJ0z5ihLnT+IM9BTJvCAdIxiBm0+lYwtJvlKvcfsymx06IxNIiFX P8G3AhUYChI1Gw6nJrXzVPgHWqk/tEOFUU5cdLrG62HMJZvGDJk7GDjD3eu0lWXBOSXF k6q5mWJDyx6qmgI9KVpJ2oTrEG0wpHdsNq4wygTpS0UBaIAPeFIMCcHW89BWrw5R4+Gt UMN9xRF9hG9NVNx5e1/ULKicCEu+kzp8IDTKMqtWRojNV5qJINMz+bj2wCddahH0/Bxo TWqVKDymB49K57LzfuRgVDpK4qFyhhhLoI5ZuqzV/K3AsuEPWF9CvQs5sTghuWv1E+vK oxRQ== 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=qRqrbCxpwtx5hLvWpJLYi+KQNOXSP7M35YblJw8hCxg=; b=qICDOYwIvLVVvQ/zrYefB6kHsZn4mRYSfd4R1wilzXnvA7HJX2HrtD8kx95x/whK1h 4L8UW9PoJUQNU4SOw98WzOUpz5LkqoJ2fSulWhUE31gLQ2LXJuf89Q1SCz7EZxL67cpj vV/crF+/vS+n85pF/yS0dR8bXxnJ1gPycQDZmJnL/VvQe/0AmYVbnsptMsl+PUq8e7sM cHu++HUWHwcvA8/5hDseBhCS47hGD7m96wcKlpf1gAlA1gZGtM+4fN2YM2YzUIs6dw0k qYCjOTICVmnuakqjJe5Ed572HZnRPJgPGPELSvrRU6GaGBpzfp9UmuyqrrhBNrUh5vxN dl7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qx4+U70K; 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 e21-20020a170906375500b0073d7d0aaa16si6288708ejc.226.2022.09.05.06.48.05 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 06:48:05 -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=qx4+U70K; 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 BB2FB3856261 for <ouuuleilei@gmail.com>; Mon, 5 Sep 2022 13:47:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB2FB3856261 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662385678; bh=qRqrbCxpwtx5hLvWpJLYi+KQNOXSP7M35YblJw8hCxg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=qx4+U70KcbtpcNCG1ysAH4YK++URyB0VtUCVzCiCofsndwu/lAzAbZSr9SNbMaoo5 S/IAlTNFTYmYwnC0m/mLCLEG03BwKhx7UEqH9SJl6UAyimC/+Pw4lWUkbr6f4S47oz y1HHNr49oOhrxymuU+UL/2HtxhlHr1FGnkaTr+7E= 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 504563858CDA for <gcc-patches@gcc.gnu.org>; Mon, 5 Sep 2022 13:47:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 504563858CDA Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-fi7sSmyQMgiyT4RUFPcghg-1; Mon, 05 Sep 2022 09:47:10 -0400 X-MC-Unique: fi7sSmyQMgiyT4RUFPcghg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6121629AB406 for <gcc-patches@gcc.gnu.org>; Mon, 5 Sep 2022 13:47:10 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.195]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EEF1A2166B26; Mon, 5 Sep 2022 13:47:09 +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 285Dl71A3330872 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 5 Sep 2022 15:47:07 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 285Dl7KG3330871; Mon, 5 Sep 2022 15:47:07 +0200 To: GCC patches <gcc-patches@gcc.gnu.org> Subject: [PATCH] Decimal floats can never be an frange::singleton_p. Date: Mon, 5 Sep 2022 15:47:01 +0200 Message-Id: <20220905134701.3330685-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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=-12.3 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> Cc: Jakub Jelinek <jakub@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?1743137732851691374?= X-GMAIL-MSGID: =?utf-8?q?1743137732851691374?= |
Series |
Decimal floats can never be an frange::singleton_p.
|
|
Commit Message
Aldy Hernandez
Sept. 5, 2022, 1:47 p.m. UTC
As Jakub mentioned in the PR, because many numbers have multiple possible representations, we can't reliably return true here. I'll commit this if tests pass. I wonder if its worth even handling decimal floats in frange, since there's a lot of things we can't represent. I suppose even though we could never propagate an actual value with VRP, we could fold conditionals (symbolic and stuff outside ranges, etc) ??. Thoughts? PR middle-end/106831 gcc/ChangeLog: * value-range.cc (frange::singleton_p): Return false for DECIMAL_FLOAT_TYPE_P. --- gcc/value-range.cc | 8 ++++++++ 1 file changed, 8 insertions(+)
Comments
On Mon, Sep 05, 2022 at 03:47:01PM +0200, Aldy Hernandez wrote: > As Jakub mentioned in the PR, because many numbers have multiple > possible representations, we can't reliably return true here. > > I'll commit this if tests pass. > > I wonder if its worth even handling decimal floats in frange, since > there's a lot of things we can't represent. I suppose even though we > could never propagate an actual value with VRP, we could fold > conditionals (symbolic and stuff outside ranges, etc) ??. > > Thoughts? > > PR middle-end/106831 > > gcc/ChangeLog: > > * value-range.cc (frange::singleton_p): Return false for > DECIMAL_FLOAT_TYPE_P. > --- > gcc/value-range.cc | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gcc/value-range.cc b/gcc/value-range.cc > index c3f668a811a..12a3750d078 100644 > --- a/gcc/value-range.cc > +++ b/gcc/value-range.cc > @@ -647,6 +647,14 @@ frange::singleton_p (tree *result) const > if (HONOR_NANS (m_type) && !get_nan ().no_p ()) > return false; > > + // Because the significand is not normalized (there is no > + // implicit leading "1"). Most values with less than 7 > + // significant digits have multiple possible representations. > + // Zero has 192 possible representations (or twice that for > + // signed zeros). The exact details (7, 192) are dependent on the format, for decimal64 it is (16, 768) and for decimal128 (34, 12288). Jakub
Final version of the patch. Disable frange for DECIMAL_FLOAT_MODE_P altogether. Tested on x86-64 Linux with regstrap as well as mpfr tests. On Mon, Sep 5, 2022 at 3:47 PM Aldy Hernandez <aldyh@redhat.com> wrote: > > As Jakub mentioned in the PR, because many numbers have multiple > possible representations, we can't reliably return true here. > > I'll commit this if tests pass. > > I wonder if its worth even handling decimal floats in frange, since > there's a lot of things we can't represent. I suppose even though we > could never propagate an actual value with VRP, we could fold > conditionals (symbolic and stuff outside ranges, etc) ??. > > Thoughts? > > PR middle-end/106831 > > gcc/ChangeLog: > > * value-range.cc (frange::singleton_p): Return false for > DECIMAL_FLOAT_TYPE_P. > --- > gcc/value-range.cc | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/gcc/value-range.cc b/gcc/value-range.cc > index c3f668a811a..12a3750d078 100644 > --- a/gcc/value-range.cc > +++ b/gcc/value-range.cc > @@ -647,6 +647,14 @@ frange::singleton_p (tree *result) const > if (HONOR_NANS (m_type) && !get_nan ().no_p ()) > return false; > > + // Because the significand is not normalized (there is no > + // implicit leading "1"). Most values with less than 7 > + // significant digits have multiple possible representations. > + // Zero has 192 possible representations (or twice that for > + // signed zeros). > + if (DECIMAL_FLOAT_TYPE_P (m_type)) > + return false; > + > // Return the appropriate zero if known. > if (HONOR_SIGNED_ZEROS (m_type) && zero_p ()) > { > -- > 2.37.1 >
diff --git a/gcc/value-range.cc b/gcc/value-range.cc index c3f668a811a..12a3750d078 100644 --- a/gcc/value-range.cc +++ b/gcc/value-range.cc @@ -647,6 +647,14 @@ frange::singleton_p (tree *result) const if (HONOR_NANS (m_type) && !get_nan ().no_p ()) return false; + // Because the significand is not normalized (there is no + // implicit leading "1"). Most values with less than 7 + // significant digits have multiple possible representations. + // Zero has 192 possible representations (or twice that for + // signed zeros). + if (DECIMAL_FLOAT_TYPE_P (m_type)) + return false; + // Return the appropriate zero if known. if (HONOR_SIGNED_ZEROS (m_type) && zero_p ()) {