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.
This commit is contained in:
Aldy Hernandez 2021-11-09 10:49:32 +01:00
parent 2b59cf475a
commit 53080c5b4c

View File

@ -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;
}