From patchwork Tue Nov 9 11:15:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 47273 Return-Path: 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 B74D53858425 for ; Tue, 9 Nov 2021 11:18:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B74D53858425 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636456685; bh=yAUSjrWw6nx713i1R1W8W7aGey24PdyFYAnfseoeEW4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=LEJUvQeASiTN/lggltkLMpy+pTXQ8JT27DRWhGyk37D3DzKz8Q4a76DIDJdsCDU2r ibQMPf6kodvwltD6SEFwuTyDsLETY4RRDEmeJWJDDTYDilrht6InpyzCs0KB23ecjF i16XYMuyNeMh9Prpfn+dR5kxpOCmLAhp5+/BDjis= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id A42293858428 for ; Tue, 9 Nov 2021 11:15:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A42293858428 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-zJ2mBUD_NaC7XXMa-3D72A-1; Tue, 09 Nov 2021 06:15:32 -0500 X-MC-Unique: zJ2mBUD_NaC7XXMa-3D72A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 286E687D54B; Tue, 9 Nov 2021 11:15:31 +0000 (UTC) Received: from abulafia.quesejoda.com (unknown [10.39.193.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1847719E7E; Tue, 9 Nov 2021 11:15:28 +0000 (UTC) Received: from abulafia.quesejoda.com (localhost [127.0.0.1]) by abulafia.quesejoda.com (8.16.1/8.15.2) with ESMTPS id 1A9BFQV6361667 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 9 Nov 2021 12:15:26 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1A9BFQuS361666; Tue, 9 Nov 2021 12:15:26 +0100 To: Jeff Law Subject: [PATCH] Return NULL for maybe_register_path when unprofitable. Date: Tue, 9 Nov 2021 12:15:20 +0100 Message-Id: <20211109111521.361580-1-aldyh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.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, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This is a minor cleanup for maybe_register_path to return NULL when the path is unprofitable. It is needed for a follow-up patch to generate better dumps from the threader. There is no change in behavior, since the only call to this function bails on !profitable_path_p. Tested on x86-64 Linux. OK? gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader::maybe_register_path): Return NULL when unprofitable. --- gcc/tree-ssa-threadbackward.c | 38 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index f9485bf9046..84249544760 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -186,11 +186,10 @@ back_threader::debug_counter () return true; } -// Register the current path for jump threading if it's profitable to -// do so. // -// Return the known taken edge out of the path, even if the path was -// not registered, or NULL if the taken edge could not be determined. +// Return NULL if it is unprofitable to thread this path, or the +// outgoing edge is unknown. Return UNREACHABLE_EDGE if the path is +// unreachable. edge back_threader::maybe_register_path () @@ -199,23 +198,26 @@ back_threader::maybe_register_path () if (taken_edge && taken_edge != UNREACHABLE_EDGE) { - // Avoid circular paths. if (m_visited_bbs.contains (taken_edge->dest)) - return UNREACHABLE_EDGE; - - bool irreducible = false; - bool profitable - = m_profit.profitable_path_p (m_path, m_name, taken_edge, &irreducible); - - if (profitable) { - if (!debug_counter ()) - return NULL; - - m_registry.register_path (m_path, taken_edge); + // Avoid circular paths by indicating there is nothing to + // see in this direction. + taken_edge = UNREACHABLE_EDGE; + } + else + { + bool irreducible = false; + if (m_profit.profitable_path_p (m_path, m_name, taken_edge, + &irreducible) + && debug_counter ()) + { + m_registry.register_path (m_path, taken_edge); - if (irreducible) - vect_free_loop_info_assumptions (m_path[0]->loop_father); + if (irreducible) + vect_free_loop_info_assumptions (m_path[0]->loop_father); + } + else + taken_edge = NULL; } } return taken_edge;