From patchwork Wed Nov 22 11:14:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746020 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp240216wru; Wed, 22 Nov 2023 03:17:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeKkRMGN2eRFFFSAQ9q92iDX5Vq70Uu7JAVq983flNU97YRUtPoGplY/2iw1Lf4Qf8FTaa X-Received: by 2002:a05:6358:718:b0:16d:bba2:e365 with SMTP id e24-20020a056358071800b0016dbba2e365mr2102227rwj.12.1700651824693; Wed, 22 Nov 2023 03:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651824; cv=pass; d=google.com; s=arc-20160816; b=qCbQvDcQ0RTvxzyX5Q8AsDrX0NggewMXbLcji1MiTNa4SkRIYxToESV+ZQg8rllwQu Sks/3nKpv/RdCBW0uQK44ku5aqOcc20zfkoQd2zFYsNjLfPKSpg3BQf2SS+zYIF52m6J nKyw9Gb6O/daGkAoGMHHY7KTlbJWjYobcSw9NceuNu0ZnGRTwle+EyKXL1Mu3K7uFGbG OgzL19NhEXF/zN/vnZEG3ObFun9pO6D4bY7t5wbfTue5orDfqSDLhJHhM8qTfl8WBUi6 1EcpoHRlF25LtrcbCdeyzTtb9htLCNCn1wo6HzMl8oaQyaORRnf78Nh3Gqsz0qspZ9iy oNlw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=Uy2qmkULXx9/O3/z10b5p14pjCdJCKcr8UpeCITyycM=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=TVctjnHYHS7ya/IrgBCMdmqt9O34gkAh58En7B4Cso9jpK+x1A3RTJ5cg7vLinQI3x FB96r03ueRIegVMzGblU+Ri3cyrNMkM4XqK8mp0JSTjqKokI/h9jtY1jEDZ7+9E57sJ1 DwcZry8EfjP2/va35ZMHMbLFibX5LXZadXOtC/Mf/WRzVN7KAMUziV0/9UtpZz0NCBWm LIBXX8UY6NiDKLZWNfrjf1nFwcOiu93oEPiQzqOAZk3TtdldxQztM0AyiCRwAKfwx2/H +W6natKB8gPN4guYN6Qrt8Ka7tr/8DaQlzBwzqS/uRzrmMSj/FswZZv0VssoMwnkcGdC RZYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdJMSGue; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bx5-20020a05622a090500b004237f541f0bsi693776qtb.768.2023.11.22.03.17.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PdJMSGue; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+patch=linaro.org@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 59E1838582A4 for ; Wed, 22 Nov 2023 11:17:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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-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 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patch=linaro.org@gcc.gnu.org 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);