Dear scheduler maintainers, Gentle ping. This patch improves debugging output, it does not touch scheduling logic.
On Wed, 22 Nov 2023 at 15:15, Maxim Kuvyrkov <maxim.kuvyr...@linaro.org> wrote: > Scheduler dependency analysis uses two main data structures: > 1. reg_pending_* data contains effects of INSN on the register file, > which is then incorporated into ... > 2. deps_desc object, which contains commulative information about all > instructions processed from deps_desc object's initialization. > > This patch adds debug dumping of (1). > > gcc/ChangeLog: > > * sched-deps.cc (print-rtl.h): Include for str_pattern_slim(). > (dump_reg_pending_data): New function. > (sched_analyze_insn): Use it. > --- > gcc/sched-deps.cc | 90 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 89 insertions(+), 1 deletion(-) > > diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc > index e0d3c97d935..f9290c82fd2 100644 > --- a/gcc/sched-deps.cc > +++ b/gcc/sched-deps.cc > @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. If not see > #include "sched-int.h" > #include "cselib.h" > #include "function-abi.h" > +#include "print-rtl.h" > > #ifdef INSN_SCHEDULING > > @@ -432,10 +433,24 @@ dep_spec_p (dep_t dep) > return false; > } > > +/* These regsets describe how a single instruction affects registers. > + Their "life-time" is restricted to a single call of > sched_analyze_insn(). > + They are populated by sched_analyze_1() and sched_analyze_2(), and > + then sched_analyze_insn() transfers data from these into > deps->reg_last[i]. > + Near the end sched_analyze_insn() clears these regsets for the next > + insn. */ > static regset reg_pending_sets; > static regset reg_pending_clobbers; > static regset reg_pending_uses; > static regset reg_pending_control_uses; > + > +/* Similar to reg_pending_* regsets, this variable specifies whether > + the current insn analyzed by sched_analyze_insn() is a scheduling > + barrier that should "split" dependencies inside a block. Internally > + sched-deps.cc does this by pretending that the barrier insn uses and > + sets all registers. > + Near the end sched_analyze_insn() transfers barrier info from this > variable > + into deps->last_reg_pending_barrier. */ > static enum reg_pending_barrier_mode reg_pending_barrier; > > /* Hard registers implicitly clobbered or used (or may be implicitly > @@ -2880,7 +2895,77 @@ get_implicit_reg_pending_clobbers (HARD_REG_SET > *temp, rtx_insn *insn) > *temp &= ~ira_no_alloc_regs; > } > > -/* Analyze an INSN with pattern X to find all dependencies. */ > +/* Dump state of reg_pending_* data for debug purposes. > + Dump only non-empty data to reduce log clobber. */ > +static void > +dump_reg_pending_data (FILE *file, rtx_insn *insn) > +{ > + fprintf (file, "\n"); > + fprintf (file, ";; sched_analysis after insn %d: %s\n", > + INSN_UID (insn), str_pattern_slim (PATTERN (insn))); > + > + if (!REG_SET_EMPTY_P (reg_pending_sets) > + || !REG_SET_EMPTY_P (reg_pending_clobbers) > + || !REG_SET_EMPTY_P (reg_pending_uses) > + || !REG_SET_EMPTY_P (reg_pending_control_uses)) > + { > + fprintf (file, ";; insn reg"); > + if (!REG_SET_EMPTY_P (reg_pending_sets)) > + { > + fprintf (file, " sets("); > + dump_regset (reg_pending_sets, file); > + fprintf (file, ")"); > + } > + if (!REG_SET_EMPTY_P (reg_pending_clobbers)) > + { > + fprintf (file, " clobbers("); > + dump_regset (reg_pending_clobbers, file); > + fprintf (file, ")"); > + } > + if (!REG_SET_EMPTY_P (reg_pending_uses)) > + { > + fprintf (file, " uses("); > + dump_regset (reg_pending_uses, file); > + fprintf (file, ")"); > + } > + if (!REG_SET_EMPTY_P (reg_pending_control_uses)) > + { > + fprintf (file, " control("); > + dump_regset (reg_pending_control_uses, file); > + fprintf (file, ")"); > + } > + fprintf (file, "\n"); > + } > + > + if (reg_pending_barrier) > + fprintf (file, ";; insn reg barrier: %d\n", reg_pending_barrier); > + > + if (!hard_reg_set_empty_p (implicit_reg_pending_clobbers) > + || !hard_reg_set_empty_p (implicit_reg_pending_uses)) > + { > + fprintf (file, ";; insn reg"); > + if (!hard_reg_set_empty_p (implicit_reg_pending_clobbers)) > + { > + print_hard_reg_set (file, implicit_reg_pending_clobbers, > + " implicit clobbers(", false); > + fprintf (file, ")"); > + } > + if (!hard_reg_set_empty_p (implicit_reg_pending_uses)) > + { > + print_hard_reg_set (file, implicit_reg_pending_uses, > + " implicit uses(", false); > + fprintf (file, ")"); > + } > + fprintf (file, "\n"); > + } > +} > + > +/* Analyze an INSN with pattern X to find all dependencies. > + This analysis uses two main data structures: > + 1. reg_pending_* data contains effects of INSN on the register file, > + which is then incorporated into ... > + 2. deps_desc object, which contains commulative information about all > + instructions processed from deps_desc object's initialization. */ > static void > sched_analyze_insn (class deps_desc *deps, rtx x, rtx_insn *insn) > { > @@ -3328,6 +3413,9 @@ sched_analyze_insn (class deps_desc *deps, rtx x, > rtx_insn *insn) > deps->last_reg_pending_barrier = reg_pending_barrier; > } > > + if (sched_verbose >= 8) > + dump_reg_pending_data (sched_dump, insn); > + > CLEAR_REG_SET (reg_pending_uses); > CLEAR_REG_SET (reg_pending_clobbers); > CLEAR_REG_SET (reg_pending_sets); > -- > 2.34.1 > > -- Maxim Kuvyrkov www.linaro.org