From patchwork Wed Apr 26 11:47:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1774056 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=m01wprYc; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q5xvs3t5Qz23vF for ; Wed, 26 Apr 2023 21:48:24 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C6AE3857006 for ; Wed, 26 Apr 2023 11:48:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C6AE3857006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682509702; bh=1OErCJxQwKVDDD5viZUeK9Du9BZrPbaEKH5mZ1GMh5E=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=m01wprYcHPEMKLK6gCgGxAUCTQjdD+FXfX0ZX0tVaTVpVpRenWXYAWMvNLn/7JNl7 Z7RkoCEtZ8zJ64Ky+6Dr5241bbBqJ2QDm4AWdwb0bKPyof6jkjPfJJXAkPJvtsnj+x Ixfl452KMBVW3e1swu7x/LrhJzbFiwgXxjkv96KA= 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 1DB403858CDA for ; Wed, 26 Apr 2023 11:48:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DB403858CDA 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-319-WpQQ_v8VPESTv5-DVHCNrA-1; Wed, 26 Apr 2023 07:47:58 -0400 X-MC-Unique: WpQQ_v8VPESTv5-DVHCNrA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F796101A55E for ; Wed, 26 Apr 2023 11:47:58 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.195.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7EE240C6E68; Wed, 26 Apr 2023 11:47:57 +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 33QBlu9I336958 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 13:47:56 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 33QBluwA336957; Wed, 26 Apr 2023 13:47:56 +0200 To: GCC patches Cc: Andrew MacLeod , Aldy Hernandez Subject: [COMMITTED] Replace ad-hoc value_range dumpers with irange::dump. Date: Wed, 26 Apr 2023 13:47:47 +0200 Message-Id: <20230426114752.336928-2-aldyh@redhat.com> In-Reply-To: <20230426114752.336928-1-aldyh@redhat.com> References: <20230426114752.336928-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 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_NONE, RCVD_IN_MSPIKE_H2, 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 Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This causes a regression in gcc.c-torture/unsorted/dump-noaddr.c. The test is asserting that two dumps are identical, but they are not because irange dumps the type which varies between runs: < VR [irange] void (*) (int) [1, +INF] > VR [irange] void (*) (int) [1, +INF] I have changed the pretty printer for irange types to pass TDF_NOUID, thus avoiding this problem. gcc/ChangeLog: * ipa-prop.cc (ipa_print_node_jump_functions_for_edge): Use vrange::dump instead of ad-hoc dumper. * tree-ssa-strlen.cc (dump_strlen_info): Same. * value-range-pretty-print.cc (visit): Pass TDF_NOUID to dump_generic_node. --- gcc/ipa-prop.cc | 9 ++------ gcc/tree-ssa-strlen.cc | 40 +++++---------------------------- gcc/value-range-pretty-print.cc | 2 +- 3 files changed, 9 insertions(+), 42 deletions(-) diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc index 1a8ff7ebb95..c6d4585aed1 100644 --- a/gcc/ipa-prop.cc +++ b/gcc/ipa-prop.cc @@ -437,13 +437,8 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) if (jump_func->m_vr) { - fprintf (f, " VR "); - fprintf (f, "%s[", - (jump_func->m_vr->kind () == VR_ANTI_RANGE) ? "~" : ""); - print_decs (wi::to_wide (jump_func->m_vr->min ()), f); - fprintf (f, ", "); - print_decs (wi::to_wide (jump_func->m_vr->max ()), f); - fprintf (f, "]\n"); + jump_func->m_vr->dump (f); + fprintf (f, "\n"); } else fprintf (f, " Unknown VR\n"); diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index 1d79034594b..dcc9e9e14ab 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -981,42 +981,14 @@ dump_strlen_info (FILE *fp, gimple *stmt, range_query *rvals) print_generic_expr (fp, si->nonzero_chars); if (TREE_CODE (si->nonzero_chars) == SSA_NAME) { - value_range_kind rng = VR_UNDEFINED; - wide_int min, max; + value_range vr; if (rvals) - { - value_range vr; - rvals->range_of_expr (vr, si->nonzero_chars, - si->stmt); - rng = vr.kind (); - if (range_int_cst_p (&vr)) - { - min = wi::to_wide (vr.min ()); - max = wi::to_wide (vr.max ()); - } - else - rng = VR_UNDEFINED; - } + rvals->range_of_expr (vr, si->nonzero_chars, + si->stmt); else - { - value_range vr; - get_range_query (cfun) - ->range_of_expr (vr, si->nonzero_chars); - rng = vr.kind (); - if (!vr.undefined_p ()) - { - min = wi::to_wide (vr.min ()); - max = wi::to_wide (vr.max ()); - } - } - - if (rng == VR_RANGE || rng == VR_ANTI_RANGE) - { - fprintf (fp, " %s[%llu, %llu]", - rng == VR_RANGE ? "" : "~", - (long long) min.to_uhwi (), - (long long) max.to_uhwi ()); - } + get_range_query (cfun)->range_of_expr (vr, + si->nonzero_chars); + vr.dump (fp); } } diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc index a11c5a621f8..8d47d8087e8 100644 --- a/gcc/value-range-pretty-print.cc +++ b/gcc/value-range-pretty-print.cc @@ -56,7 +56,7 @@ vrange_printer::visit (const irange &r) const pp_string (pp, "UNDEFINED"); return; } - dump_generic_node (pp, r.type (), 0, TDF_NONE, false); + dump_generic_node (pp, r.type (), 0, TDF_NONE | TDF_NOUID, false); pp_character (pp, ' '); if (r.varying_p ()) {