From patchwork Thu Aug 18 16:13:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp379633pxh; Thu, 18 Aug 2022 09:14:23 -0700 (PDT) X-Google-Smtp-Source: AA6agR6UUemTOuK1jTQba36FfLXmtzns7L8hNhivKQMoaFT2kz+eMfzHf0wPLTV6+Uv/HNf93SBJ X-Received: by 2002:aa7:cd99:0:b0:43c:4f9c:4977 with SMTP id x25-20020aa7cd99000000b0043c4f9c4977mr2851053edv.303.1660839262952; Thu, 18 Aug 2022 09:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660839262; cv=none; d=google.com; s=arc-20160816; b=T/1Uay8aj4NV2qo67/t5kciq3A7ANgQolqzy6C6y+oBWGlKo7JT6f1t818bPkrEd/k BkIeGywb+x6Rjl9W0TxclwR4dBEkhenN4xKESa+/osMuqsA3qRtBAeFeMsipm7BkQ4kS Shn/rhlojGgIuZQ766nFxdnnmA9mN0un2xe7jJmx+wmlCyRRt6V0wNwzOKhDd2WsxHg9 j0+9WmMeE4wNaz25Tzv6ALGvdLNuvHtUT111Uz7+qpDr+wLbZrsjv1NezLWfaHRq78r8 BD4ulCPRoVqsjS8EYGoVcqTs2fiiLyeQ/SmL2h7MDMfjBGATPFR1C46mHSBXJKaCfO3L JPPA== 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=WjOZkyaMH6/xklltLizaokp6yPV77SmHo+XJQnv5Xxk=; b=tpj13hD1v3K6Jdv94r0CL5TZ4GuZmYALM3yJQAXLdu0ji/ucoIwKI59j6IiNdwsD/t PdEA9OlmWzWy2f/0X3mZRcT3LEZ08NINo/bOagYM8fYHsUtWAe4R321AKnSUp5WYmTPS 5vfqvrvfg0c10Tm+MDaPAlRsDBvxRAIQiVxCXrSnPGBuYVs7L/VnJJUnDz1LrP5sNevY mi5JtzV63DCgzixaOhvPmgAjeFYWtOVepwjr1NsEy430qGPMJdawBAjRjdrTw9bVejJS ChF4m0g/EvCZ3HbdR8NYzvxi4UWMOXQiX8qbqXwl6deaBPNcmVc0rXfMOc4HdEeHMkXp +X1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=wtVlnnPi; 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 hp28-20020a1709073e1c00b007316c60ed16si1537498ejc.749.2022.08.18.09.14.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 09:14:22 -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=wtVlnnPi; 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 55A883858438 for ; Thu, 18 Aug 2022 16:14:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55A883858438 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660839261; bh=WjOZkyaMH6/xklltLizaokp6yPV77SmHo+XJQnv5Xxk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=wtVlnnPiq/VfJAR1FiYqB/KM5QvLoLtqgVMb7Bayr4jxmX8ccaOzlydG4TpDv8Xhr dsSYN8ObaiD5Z8uEFdQ4mKGNSI+DPN9UrkGknYGy82txgi0+lM0Ey2aVEbDXa0I1Hb a3HJcb7XAuvUJt34mM8PjzBMyokT7ZlSLK4CzE9k= 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 2A5AB3858C2D for ; Thu, 18 Aug 2022 16:13:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A5AB3858C2D 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-488-Hrgs60_jPiavDJbwHYB1JA-1; Thu, 18 Aug 2022 12:13:33 -0400 X-MC-Unique: Hrgs60_jPiavDJbwHYB1JA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0BB3382ECCB; Thu, 18 Aug 2022 16:13:32 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.194.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF61D492CA4; Thu, 18 Aug 2022 16:13:31 +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 27IGDTTq642970 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 18 Aug 2022 18:13:29 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 27IGDSJc642969; Thu, 18 Aug 2022 18:13:28 +0200 To: Richard Biener Subject: [PATCH] Remove path_range_query constructor that takes an edge. Date: Thu, 18 Aug 2022 18:13:23 +0200 Message-Id: <20220818161323.642918-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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, 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 Cc: GCC patches 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?1741516191017967939?= X-GMAIL-MSGID: =?utf-8?q?1741516191017967939?= The path_range_query constructor that takes an edge is really a convenience function for the loop-ch pass. It feels wrong to pollute the API with such a specialized function that could be done with a small inline function closer to its user. As an added benefit, we remove one use of reset_path. The last remaining one is the forward threader one. OK? gcc/ChangeLog: * gimple-range-path.cc (path_range_query::path_range_query): Remove constructor that takes edge. * gimple-range-path.h (class path_range_query): Same. * tree-ssa-loop-ch.cc (edge_range_query): New. (entry_loop_condition_is_static): Call edge_range_query. --- gcc/gimple-range-path.cc | 15 --------------- gcc/gimple-range-path.h | 1 - gcc/tree-ssa-loop-ch.cc | 17 +++++++++++++++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index ba7c2ed9b47..bc2879c0c57 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -59,21 +59,6 @@ path_range_query::path_range_query (gimple_ranger &ranger, bool resolve) m_oracle = new path_oracle (m_ranger.oracle ()); } -path_range_query::path_range_query (gimple_ranger &ranger, - edge e, - bool resolve) - : m_cache (new ssa_global_cache), - m_has_cache_entry (BITMAP_ALLOC (NULL)), - m_ranger (ranger), - m_resolve (resolve) -{ - m_oracle = new path_oracle (m_ranger.oracle ()); - auto_vec bbs (2); - bbs.quick_push (e->dest); - bbs.quick_push (e->src); - reset_path (bbs, NULL); -} - path_range_query::~path_range_query () { delete m_oracle; diff --git a/gcc/gimple-range-path.h b/gcc/gimple-range-path.h index 483fde0d431..9f2d6d92dab 100644 --- a/gcc/gimple-range-path.h +++ b/gcc/gimple-range-path.h @@ -37,7 +37,6 @@ public: const bitmap_head *dependencies = NULL, bool resolve = true); path_range_query (gimple_ranger &ranger, bool resolve = true); - path_range_query (gimple_ranger &ranger, edge e, bool resolve = true); virtual ~path_range_query (); void reset_path (const vec &, const bitmap_head *dependencies); bool range_of_expr (vrange &r, tree name, gimple * = NULL) override; diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc index 96816b89287..9c316887d5b 100644 --- a/gcc/tree-ssa-loop-ch.cc +++ b/gcc/tree-ssa-loop-ch.cc @@ -45,6 +45,20 @@ along with GCC; see the file COPYING3. If not see increases effectiveness of code motion optimizations, and reduces the need for loop preconditioning. */ +/* Given a path through edge E, whose last statement is COND, return + the range of the solved conditional in R. */ + +static void +edge_range_query (irange &r, edge e, gcond *cond, gimple_ranger &ranger) +{ + auto_vec path (2); + path.safe_push (e->dest); + path.safe_push (e->src); + path_range_query query (ranger, path); + if (!query.range_of_stmt (r, cond)) + r.set_varying (boolean_type_node); +} + /* Return true if the condition on the first iteration of the loop can be statically determined. */ @@ -72,8 +86,7 @@ entry_loop_condition_is_static (class loop *l, gimple_ranger *ranger) desired_static_value = boolean_true_node; int_range<2> r; - path_range_query query (*ranger, e); - query.range_of_stmt (r, last); + edge_range_query (r, e, last, *ranger); return r == int_range<2> (desired_static_value, desired_static_value); }