From patchwork Tue Nov 9 11:15:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 47272 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 26DA63858000 for ; Tue, 9 Nov 2021 11:17:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26DA63858000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636456629; bh=EL8KMrpg6Fb35weGGx8A+u8JbVl1G/jHszy2WAL2Yxc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=cwp3KFPI2GKWvzG5NT4Hw2WMoAjjOpxQ5H77kO+xQl0NZ/2pZRUvhf+sEQCjUVfrK f4h6mVsQRDVf/2wbHhKsQFu1wzzqUIvFDqbe8TGkhcTKOS+4HnULPI6uNIIGfhIGVR RV2FH+Ht6x0NfdJWVFWf5h0g8ua7TaoXqyoMTYJU= 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 D240A3858428 for ; Tue, 9 Nov 2021 11:15:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D240A3858428 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-302-llR62AffOKek3lnZfoIEYA-1; Tue, 09 Nov 2021 06:15:32 -0500 X-MC-Unique: llR62AffOKek3lnZfoIEYA-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 2B2F087D54C; 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 A98E367843; Tue, 9 Nov 2021 11:15:29 +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 1A9BFRlm361671 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 9 Nov 2021 12:15:27 +0100 Received: (from aldyh@localhost) by abulafia.quesejoda.com (8.16.1/8.16.1/Submit) id 1A9BFRMI361670; Tue, 9 Nov 2021 12:15:27 +0100 To: Jeff Law Subject: [PATCH] Dump details of an attempt to register a jump threading path. Date: Tue, 9 Nov 2021 12:15:21 +0100 Message-Id: <20211109111521.361580-2-aldyh@redhat.com> In-Reply-To: <20211109111521.361580-1-aldyh@redhat.com> References: <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" The goal with these sets of patches is to improve the detailed dumps for the threader, as I hope we eventually reach the point when I'm not the only one looking at these dumps ;-). This patch adds candidate paths to the detailed threading dumps to make it easier to see the decisions the threader makes. With it we can now grep for the discovery logic in action: $ grep ^path: a.ii.*thread* a.ii.034t.ethread:path: 4->5->xx REJECTED a.ii.034t.ethread:path: 3->5->8 SUCCESS a.ii.034t.ethread:path: 4->5->6 SUCCESS a.ii.034t.ethread:path: 0->2->xx REJECTED a.ii.034t.ethread:path: 0->2->xx REJECTED ... ... a.ii.111t.threadfull1:path: 14->22->23->xx REJECTED (unreachable) a.ii.111t.threadfull1:path: 15->22->23->xx REJECTED (unreachable) a.ii.111t.threadfull1:path: 16->22->23->xx REJECTED (unreachable) In addition to this, if --param=threader-debug=all is used, one can see the entire chain of events leading up to the ultimate threading decision: ============================================== path_range_query: compute_ranges for path: 2->5 Registering killing_def (path_oracle) _3 Registering killing_def (path_oracle) _1 range_defined_in_block (BB2) for _1 is _Bool VARYING Registering killing_def (path_oracle) _2 range_defined_in_block (BB2) for _2 is _Bool VARYING range_defined_in_block (BB2) for _3 is _Bool VARYING outgoing_edge_range_p for b_10(D) on edge 2->5 is int VARYING ... ... [BBs and gimple along path] ... path: 2->5->xx REJECTED Tested on x86-64 Linux. OK? gcc/ChangeLog: * tree-ssa-threadbackward.c (back_threader::maybe_register_path_dump): New. (back_threader::maybe_register_path): Call maybe_register_path_dump. --- gcc/tree-ssa-threadbackward.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 84249544760..74b5f361f45 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -89,6 +89,7 @@ private: void find_paths (basic_block bb, tree name); bool debug_counter (); edge maybe_register_path (); + void maybe_register_path_dump (edge taken_edge); void find_paths_to_names (basic_block bb, bitmap imports); bool resolve_def (tree name, bitmap interesting, vec &worklist); void resolve_phi (gphi *phi, bitmap imports); @@ -186,6 +187,35 @@ back_threader::debug_counter () return true; } +// Dump details of an attempt to register a path. + +void +back_threader::maybe_register_path_dump (edge taken) +{ + if (m_path.is_empty ()) + return; + + fprintf (dump_file, "path: "); + + for (unsigned i = m_path.length (); i > 0; --i) + { + basic_block bb = m_path[i - 1]; + fprintf (dump_file, "%d", bb->index); + if (i > 1) + fprintf (dump_file, "->"); + } + fprintf (dump_file, "->"); + + if (taken == UNREACHABLE_EDGE) + fprintf (dump_file, "xx REJECTED (unreachable)\n"); + else if (taken) + fprintf (dump_file, "%d SUCCESS\n", taken->dest->index); + else + fprintf (dump_file, "xx REJECTED\n"); +} + +// If an outgoing edge can be determined out of the current path, +// register it for jump threading and return the taken edge. // // Return NULL if it is unprofitable to thread this path, or the // outgoing edge is unknown. Return UNREACHABLE_EDGE if the path is @@ -220,6 +250,10 @@ back_threader::maybe_register_path () taken_edge = NULL; } } + + if (dump_file && (dump_flags & TDF_DETAILS)) + maybe_register_path_dump (taken_edge); + return taken_edge; }