From patchwork Thu Sep 22 16:49:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1379 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp293200wrt; Thu, 22 Sep 2022 09:53:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM424cTVjWbHWd3GRIa/ePny7NzXyy5css0F+ymQB5u6fCDHpto6W13Z50PY8DtlvpLKuZbZ X-Received: by 2002:a05:6402:1f84:b0:455:27b8:27aa with SMTP id c4-20020a0564021f8400b0045527b827aamr3316663edc.243.1663865580631; Thu, 22 Sep 2022 09:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663865580; cv=none; d=google.com; s=arc-20160816; b=ny/TWqBcSejcg2RTZafi21cCfYzZr4cG9HP5gvwAxenhTQBojnLvTIT+/kmHOyP5Wk YasADcd9wxslk6i5H40PUhZPSIU6w0aKiCDB1kYD9VmbR8wAvaEgaBC2Tv1lt+FF3tB1 /hHg0P486naqKo3EVm1likmfHQjI+/Ewpxkh7npsAax8nb2Ud3RLOR1Rjlg2ltoOFT4G YsGddrA63iyusB6XBRlUdaqw51twIo9SBET4WaQh9YZzJBZ2EEKvpvENjOT5HY3jESWw /Gikrd4cnQSk/nPQjg51sa4BHNSuCkj3ENphchlkIiRxUJRpzR+qhXdzkCmN+2ijZlau mkJg== 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=/VO81USOHq2eKsGUap3wwfAFWNECGoZZ3ZHViB6n4pU=; b=p19Z/iCzxgWmrEyC3qjj0YuCyUVFtbI3B2JW2pTMhPEtTl6rUy8kAgMKMQsZLJ0k7l e57jZIMVkFFOAomJVAJyX1ttrBF6FC+FRKlWqofkUSsQFDzfkqx/6xE70piha9ryENsv aex/2kg0SPFvF8NLTJEqKrGo5yP+rP6VmvdUB4HzL43t3jbpPjsidm+JA0l2dcVG4jfj wdbCc9gLcyaOkfI5jrO3u+Gk5vB3tfi/GK970EumOl8jrXfqowpC5G1CCSCTIBEq4bdC pfnQredZ/nAUGYcuj30hB7t/58dW9b67DdXtupTSjziI6Sl0oEtRbC/V+h9t+/izh69G MjVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=RlXBeJ50; 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 ho35-20020a1709070ea300b0073dab845a38si6553288ejc.346.2022.09.22.09.53.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 09:53:00 -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=RlXBeJ50; 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 1EDD33857351 for ; Thu, 22 Sep 2022 16:52:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1EDD33857351 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663865569; bh=/VO81USOHq2eKsGUap3wwfAFWNECGoZZ3ZHViB6n4pU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RlXBeJ50TqUYtVSHB31rGVeUkD1w++PdwdXUL47fjRDIvyiqPiMZwB4tIpomciIYK kEp+0zjjj2PnR9NkwuQBX2cS021+ynnimKWlcDld+Ww+OizmuekDHdDSODE95J9+vT rdd2pIvN5yvv5a2dxfyUKBKkH2cJL10KEwnbImJM= 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 95E5B3857C61 for ; Thu, 22 Sep 2022 16:51:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95E5B3857C61 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-28-RQzgbjriPcGVCu-f2pe-bQ-1; Thu, 22 Sep 2022 12:49:36 -0400 X-MC-Unique: RQzgbjriPcGVCu-f2pe-bQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 942CA872846; Thu, 22 Sep 2022 16:49:16 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3703540C213F; Thu, 22 Sep 2022 16:49:16 +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 28MGnERD2566230 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 22 Sep 2022 18:49:14 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 28MGnEva2566229; Thu, 22 Sep 2022 18:49:14 +0200 To: GCC patches Subject: [PATCH] frange: dump hex values when dumping FP numbers. Date: Thu, 22 Sep 2022 18:49:10 +0200 Message-Id: <20220922164911.2566143-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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 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?1744689515244645744?= X-GMAIL-MSGID: =?utf-8?q?1744689515244645744?= It has been suggested that if we start bumping numbers by an ULP when calculating open ranges (for example the numbers less than 3.0) that dumping these will become increasingly harder to read, and instead we should opt for the hex representation. I still find the floating point representation easier to read for most numbers, but perhaps we could have both? With this patch this is the representation for [15.0, 20.0]: [frange] float [1.5e+1 (0x0.fp+4), 2.0e+1 (0x0.ap+5)] Would you find this useful, or should we stick to the hex representation only (or something altogether different)? Tested on x86-64 Linux. gcc/ChangeLog: * value-range-pretty-print.cc (vrange_printer::print_real_value): New. (vrange_printer::visit): Call print_real_value. * value-range-pretty-print.h: New print_real_value. --- gcc/value-range-pretty-print.cc | 16 ++++++++++++---- gcc/value-range-pretty-print.h | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc index eb7442229ba..51be037c254 100644 --- a/gcc/value-range-pretty-print.cc +++ b/gcc/value-range-pretty-print.cc @@ -117,6 +117,16 @@ vrange_printer::print_irange_bitmasks (const irange &r) const pp_string (pp, buf); } +void +vrange_printer::print_real_value (tree type, const REAL_VALUE_TYPE &r) const +{ + char s[60]; + tree t = build_real (type, r); + dump_generic_node (pp, t, 0, TDF_NONE, false); + real_to_hexadecimal (s, &r, sizeof (s), 0, 1); + pp_printf (pp, " (%s)", s); +} + // Print an frange. void @@ -141,11 +151,9 @@ vrange_printer::visit (const frange &r) const bool has_endpoints = !r.known_isnan (); if (has_endpoints) { - dump_generic_node (pp, - build_real (type, r.lower_bound ()), 0, TDF_NONE, false); + print_real_value (type, r.lower_bound ()); pp_string (pp, ", "); - dump_generic_node (pp, - build_real (type, r.upper_bound ()), 0, TDF_NONE, false); + print_real_value (type, r.upper_bound ()); } pp_character (pp, ']'); print_frange_nan (r); diff --git a/gcc/value-range-pretty-print.h b/gcc/value-range-pretty-print.h index 20c26598fe7..a9ae5a7b4cc 100644 --- a/gcc/value-range-pretty-print.h +++ b/gcc/value-range-pretty-print.h @@ -32,6 +32,7 @@ private: void print_irange_bound (const wide_int &w, tree type) const; void print_irange_bitmasks (const irange &) const; void print_frange_nan (const frange &) const; + void print_real_value (tree type, const REAL_VALUE_TYPE &r) const; pretty_printer *pp; };