From patchwork Wed Aug 17 16:09:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 1667382 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=8.43.85.97; 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=JeO1Px1j; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 4M7Cf25f53z1ygV for ; Thu, 18 Aug 2022 02:10:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C03D3858C53 for ; Wed, 17 Aug 2022 16:09:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C03D3858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660752598; bh=qHpAAjcJ40lyev7nzjgS4h0IXrQ3GdNKZgFW9z4t0g0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=JeO1Px1jhKqiLplQT+AtPKpG98qvWaeIA+HA/wQjbnFX2BalIqbb59jdiruNaCro0 RaGT+AkCUyVhaGf3PZF/xIa5HhAxDlbwJXK7fL3MCZxp4UBqtqk+Oa54XdFDyNduIM PBhmEOqoUP/QdcvBtmmKlg6/Lo3lGwT9y1U4M6Zk= 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 935193858D1E for ; Wed, 17 Aug 2022 16:09:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 935193858D1E 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-325-j8_M1rjOMO6vYJ_aMB_u5g-1; Wed, 17 Aug 2022 12:09:34 -0400 X-MC-Unique: j8_M1rjOMO6vYJ_aMB_u5g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF2328032E3 for ; Wed, 17 Aug 2022 16:09:33 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.192.164]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A3C51121315; Wed, 17 Aug 2022 16:09:32 +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 27HG9T1i526521 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 17 Aug 2022 18:09:29 +0200 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.17.1/8.17.1/Submit) id 27HG9T7W526520; Wed, 17 Aug 2022 18:09:29 +0200 To: GCC patches Subject: [PATCH] Reset root oracle from path_oracle::reset_path. Date: Wed, 17 Aug 2022 18:09:20 +0200 Message-Id: <20220817160920.526474-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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, 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" When we cross a backedge in the path solver, we reset the path relations and nuke the root oracle. However, we forget to reset it for the next path. This is causing us to miss threads because subsequent paths will have no root oracle to use. With this patch we get 201 more threads in the threadfull passes in my .ii files and 118 more overall (DOM gets less because threadfull runs before). Normally, I'd recommend this for the GCC 12 branch, but considering how sensitive other passes are to jump threading, and that there is no PR associated with this, perhaps we should leave this out. Up to the release maintainers of course. Andrew, you OK with this for trunk? gcc/ChangeLog: * gimple-range-path.cc (path_range_query::compute_ranges_in_block): Remove set_root_oracle call. (path_range_query::compute_ranges): Pass ranger oracle to reset_path. * value-relation.cc (path_oracle::reset_path): Set root oracle. * value-relation.h (path_oracle::reset_path): Add root oracle argument. --- gcc/gimple-range-path.cc | 8 +++++--- gcc/value-relation.cc | 6 ++++-- gcc/value-relation.h | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index c99d77dd340..73e248b7e0b 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -435,11 +435,10 @@ path_range_query::compute_ranges_in_block (basic_block bb) e->src->index, e->dest->index); path_oracle *p = get_path_oracle (); - p->reset_path (); // ?? Instead of nuking the root oracle altogether, we could // reset the path oracle to search for relations from the top of // the loop with the root oracle. Something for future development. - p->set_root_oracle (nullptr); + p->reset_path (); } gori_compute &g = m_ranger->gori (); @@ -615,7 +614,10 @@ path_range_query::compute_ranges (const vec &path, compute_exit_dependencies (m_exit_dependencies, m_path); if (m_resolve) - get_path_oracle ()->reset_path (); + { + path_oracle *p = get_path_oracle (); + p->reset_path (m_ranger->oracle ()); + } if (DEBUG_SOLVER) { diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index 3f0957ccdd6..7fc22d30126 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -1513,11 +1513,13 @@ path_oracle::query_relation (basic_block bb, tree ssa1, tree ssa2) return query_relation (bb, equiv_1, equiv_2); } -// Reset any relations registered on this path. +// Reset any relations registered on this path. ORACLE is the root +// oracle to use. void -path_oracle::reset_path () +path_oracle::reset_path (relation_oracle *oracle) { + set_root_oracle (oracle); m_equiv.m_next = NULL; bitmap_clear (m_equiv.m_names); m_relations.m_head = NULL; diff --git a/gcc/value-relation.h b/gcc/value-relation.h index 77e12085eea..64884a8eea2 100644 --- a/gcc/value-relation.h +++ b/gcc/value-relation.h @@ -242,7 +242,7 @@ public: relation_kind query_relation (basic_block, tree, tree) final override; relation_kind query_relation (basic_block, const_bitmap, const_bitmap) final override; - void reset_path (); + void reset_path (relation_oracle *oracle = NULL); void set_root_oracle (relation_oracle *oracle) { m_root = oracle; } void dump (FILE *, basic_block) const final override; void dump (FILE *) const final override;