From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 1165A3858C50 for ; Mon, 15 Jan 2024 13:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1165A3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1165A3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705324025; cv=none; b=J+0LmWpZBkOnG24XWQVJLBWQgFpniMzFqNklnVws6Qfo2Q+NCmTfnziRHV26q5tV9KLLheCgDvqu2pcIiy0ARH4EU8j25guSMEqSuaJRcjCcvlSMD3lbMLpTu42/9TPzLpS6vInZ2bKpC4cPaK+vbbO+A36zl8DeyFZzO5JAixQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705324025; c=relaxed/simple; bh=+kSleOCtP5Dk37jiaerg6/0RBnVjJMC007Tg0Z8f6aQ=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=qHJNrvfniuVV8KFn7Pql3GF+CnRCraLI1JiiJnw64GUycQBdil4DhWpKHXHwzQL3EhVMi0p3NAaYdlVpRWKLutwNT69OSlmmpwsvA9Tj+xb6J8wsuemtZNi4/goDrXJSYuaEaJ6WFH+iEOnu4TtGvHoOwpOGHn3GGfum/Y7JeDo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6daf21d1d5dso1283880b3a.1 for ; Mon, 15 Jan 2024 05:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705324018; x=1705928818; darn=gcc.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eXNg5v83zCYTKh2y9ccoylzYHVA+VxvdNvqprUwRzkg=; b=pP9QqaHdADEv9QH6vteLT0bMNjotriFSXWPceZ/D1hVQfUDQ0NusKXmxTxq7M9S5uE mqOMhWjUzFGvYxznSSshKIe5oZ5nx4q5VL1dVEpB7jtMXFnNjXikp47n8sNWtQNFIzBx L2hXTEA7TkN2ReufBFzBvfrnIJjCtsEmxoW/iX76JfuVUQXfg781bmMtX7OMBiqKYIjA y09SsUPH8yx3YWTTNrMbQiXwmWWQpSFuL0KkxwZ8R8HjmwQK53uPyMSJj2ljc327m3BT PQy3/Ca/ebhI+G1NS5kQHhsN22DwvrFd5npK/dXaqoTQH0dt71eoG4Og3aiPU8tDslbv rDYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705324018; x=1705928818; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eXNg5v83zCYTKh2y9ccoylzYHVA+VxvdNvqprUwRzkg=; b=q617dXBRHSmNG1kKI7Krll5zBRtdaijUW5OxtIDCQHAjwfE95Y+FBv0064ggBMo2MS qJAHkM+jdVH0cBmS8b0iJdOhxtpEIT+MS92v1yMPsJgynbTSOeaH5ACxvTIQFbujahZO 6zoZeTmf0F25AZ4FXos6d34IRXopvcv8IPU6vD/LOYgk+wBssBfX+YFIwgKX9UXPZ4dP tc1vrcytMo+spx92BUgK/a91J2usgMOcruPosWcOo/SIy7KpIbFbh/d1bxv88YM1VPbP 0g+o9+fixAuKsnYrqcGFunrLkL8FA0K6wOxeYTk+lPSVzfDr195ZHAMex+o3Vfvo4Jmj ju8g== X-Gm-Message-State: AOJu0Yww0QJ7rJZa2zyiylb5Y3nsUSG0uWZ/KkDsBBXJphmEVGcIn2U0 ERoINstqv8rQTkKezz0BAkE+XWtTHHk7dl8wYaGCQdhvKxbKazUIdMimXGQ= X-Google-Smtp-Source: AGHT+IEZHjG/h5ti5cXgbZdJdkHXMZnnunLaoaFpqya0JLGrS6Zlr2wfgV65Ndkm8FEarws92rCi0ttcN4CR/uhAkwY= X-Received: by 2002:a05:6a20:d493:b0:19b:1dc6:60ce with SMTP id im19-20020a056a20d49300b0019b1dc660cemr622414pzb.1.1705324018569; Mon, 15 Jan 2024 05:06:58 -0800 (PST) MIME-Version: 1.0 References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> <20231122111415.815147-8-maxim.kuvyrkov@linaro.org> In-Reply-To: <20231122111415.815147-8-maxim.kuvyrkov@linaro.org> From: Maxim Kuvyrkov Date: Mon, 15 Jan 2024 17:06:46 +0400 Message-ID: Subject: Re: [PATCH v3 7/8] Improve logging of register data in scheduler dependency analysis To: gcc-patches@gcc.gnu.org Cc: Bernd Schmidt , Vladimir Makarov , Jeff Law , Alexander Monakov , Richard Guenther Content-Type: multipart/alternative; boundary="0000000000005ab02d060efbb018" X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000005ab02d060efbb018 Content-Type: text/plain; charset="UTF-8" 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 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 --0000000000005ab02d060efbb018--