Message ID | 20220905134701.3330685-1-aldyh@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CED203856DFE for <patchwork@sourceware.org>; Mon, 5 Sep 2022 13:47:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CED203856DFE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662385664; 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=dSvbOkctU80PJgxXlH7aOBGuRb1Gmro/oYDDKSEJ+eEcnCEVrpFJgwZ0Wmm89Fmn9 I+j3ZrkUEhJcLOMWwG3sLisy12CfHSHeACRVNP4bGPvax4N/hUZZN8qm3wzOOC03lo UQix42aloag0jL72RevdLjQKTR9Onfy0IXNczqaE= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
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 ()) {