From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 6E2333858C5E for ; Wed, 22 Nov 2023 11:15:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6E2333858C5E 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 6E2333858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::135 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651707; cv=none; b=GXScnhDw8iM0+uLWxGPxcCgj6HCdpqGHIt6pqRrByeiOywFvszNsIQ7VRPL5O0OSipOIcaf9Rkc5ZGJdct3NwSE6pkMcWDCsZc2R37zyWMt/5X/FWzNi0pUnepbLOuN0D57hzva8cdu3/vZj9EFMDsw26IseJTGjiaSMhdQSwbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651707; c=relaxed/simple; bh=8O+lkZVfls08MzFQJo/N9jmVaNev/gI/Yc2EOyChN/A=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=XHq4o5eT1WO+9d6ukQ/ZrZ1o29UdpwVQsGLVfXYiYFJySJHUyEEQHYy4U8TQLn5bdxpkMI0jybwaZUwFZcuHCXly96DcXxyWWroJqxYrUbn5kdftPzsH753O4+TOs2YQ3PH3mZW6eclU/vCv0eKqgFAG1szAfFrdkvbCD1fsR/8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50799fe3422so1477647e87.1 for ; Wed, 22 Nov 2023 03:15:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651703; x=1701256503; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Uy2qmkULXx9/O3/z10b5p14pjCdJCKcr8UpeCITyycM=; b=PdJMSGueXwiylFciQ4BUZZNsFmf3T+AWzFhMr4rd0ahciTMitGEzbJHIT5mG5kg4h9 jAfGsOMVnpjy/z5wmIlHI1OJFTDNsjoT8Rc4zWGVV9ZNuBtreDAGpB04nwe+S/NxjdCJ FX6LWl1oLIJyF6lyR0vcBwS4dnSS7CJh7CtHZHgkx7/y1kl29STVALdNxFOewdL4oK52 IJMh2c1FgC9qPAp8mcw2JpVRdUTKwsgm8jDM5eoXIVX1AehzAnyUNVyYmeUDuCcYVXtd uDDpeGswsLk3E5r80yQRghmgq9wlo5j1o1dJX2GxuWliV95/hToPab9P+acdpB0UyJed L8FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651703; x=1701256503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Uy2qmkULXx9/O3/z10b5p14pjCdJCKcr8UpeCITyycM=; b=aLbpu7eAhSBv5sVbdHDDPTc8dZL26JnJM3VRHSghELU7GNlB+NFVCaN1f7Evs7KCIb APYjKTbP/uVacGF9OtIKnrC2Im8cJb3qe4gLBi/+JKFCyrUEjKYDY2WqPaxh6WdYnOqi oy/3wt32XAVjKe1vlbZKSOEPiU/UW4Z0Aq5vjIxpT5WoiWfDKGpGS0xUrmwbReCIO1ey aYLmmSNXuNylUROEt32TmIrGnUH+Ze7bt6PYlMa7V3008ZpFRiEGhNzT+haqJmIzhTlX rR2BkPqvEmX2LlzjAnucSUa94x8oMiHy/6GEcuNrKsuu5j2QbOIKLdF7yzGbAVK+Z+Hg 77EQ== X-Gm-Message-State: AOJu0Yx+H3wRvlsV/fkmJKfHqFw3LKy0u7GVdRNsfS+dnHxCIhuMwuA6 HfJ/vAAtBG2mHbyHXUiPsR5dFJAnNf1ZwjfSYnxb3zs= X-Google-Smtp-Source: AGHT+IH0ZNNheqeGDPY02sLggtG24aUhILW0eld/KjPAiivYZpUW6LIm/a4EkZykulspxmwfErHeig== X-Received: by 2002:a05:6512:3ba3:b0:508:1a9d:d768 with SMTP id g35-20020a0565123ba300b005081a9dd768mr1567475lfv.4.1700651703310; Wed, 22 Nov 2023 03:15:03 -0800 (PST) Received: from localhost.localdomain (static.225.72.216.95.clients.your-server.de. [95.216.72.225]) by smtp.gmail.com with ESMTPSA id t13-20020a195f0d000000b0050919538b00sm1848553lfb.79.2023.11.22.03.15.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:15:02 -0800 (PST) From: Maxim Kuvyrkov To: gcc-patches@gcc.gnu.org Cc: Maxim Kuvyrkov , Bernd Schmidt , Vladimir Makarov , Jeff Law , Alexander Monakov , Richard Guenther Subject: [PATCH v3 7/8] Improve logging of register data in scheduler dependency analysis Date: Wed, 22 Nov 2023 11:14:14 +0000 Message-Id: <20231122111415.815147-8-maxim.kuvyrkov@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> References: <20231120120649.672893-1-maxim.kuvyrkov@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: 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