public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5069] Dump details of an attempt to register a jump threading path.
Date: Tue,  9 Nov 2021 17:23:56 +0000 (GMT)	[thread overview]
Message-ID: <20211109172356.75AD9385842F@sourceware.org> (raw)

https://gcc.gnu.org/g:53080c5b4ce3742d20a0aa4643203215f20aadf6

commit r12-5069-g53080c5b4ce3742d20a0aa4643203215f20aadf6
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Tue Nov 9 10:49:32 2021 +0100

    Dump details of an attempt to register a jump threading path.
    
    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.
    
    gcc/ChangeLog:
    
            * tree-ssa-threadbackward.c
            (back_threader::maybe_register_path_dump): New.
            (back_threader::maybe_register_path): Call maybe_register_path_dump.

Diff:
---
 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<tree> &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;
 }


                 reply	other threads:[~2021-11-09 17:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211109172356.75AD9385842F@sourceware.org \
    --to=aldyh@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).