From patchwork Mon Nov 20 12:06:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 745354 Delivered-To: patch@linaro.org Received: by 2002:a5d:5052:0:b0:32d:baff:b0ca with SMTP id h18csp1240432wrt; Mon, 20 Nov 2023 04:08:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsJx3MD/evGKe+ZknZnKLAY50FNh0aHqbdO0pEAdLDASRes5K3RV6gc4Zi6VkoVokAnIj/ X-Received: by 2002:a05:620a:1aa7:b0:77b:d0f0:962b with SMTP id bl39-20020a05620a1aa700b0077bd0f0962bmr12175102qkb.23.1700482091167; Mon, 20 Nov 2023 04:08:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700482091; cv=pass; d=google.com; s=arc-20160816; b=MeywHnvSfbIkA1YyKUx+fMy3C6cCKo8YAJVMOSXllMZSYTDGClUk9lhcJXGn95WO4h YcQoCNIzINRIrE9UOveOXM3uiBs0MimWj0mtv5UJWPLXS0sAL6k9HHyBLIHh++vlJ8eE HRQnG7O7Y2UvEyqx3k/KDCX4loTKAr0DtJlcJfH5vKywbQSHsyL0fHCQV7cu0/0sp6qM pQoei02kSWYz8aMXKUKBy2VQWY4PXjr4/hRi3HGYk87fWdma4kA27+6lkH3nbYF2cgCD G5URD9j0iPRNJJ41YV27iAwGUczaB89wQ2Y98JFdSG0VUEVRPzI2+bHAQkqTefjGh68E M2rQ== 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=XWSaJJ/f8+1zQVVK8Gk1mrKZPYAA8REpQy73jsEi7HY=; fh=98edGTG9zj/Nk59bsyQAUrc4IlBzGyUrREu3W2WgiHA=; b=YvowO5+y77CMHEBFvg0bOcZWPjLVehbGbqBaypwkEK44G8uWffM9VLAc3BnU0srzKC uZJfiJi5qqkaEVUMcRB55pt0mpwe54IZXdRyGphJ0vkr3H/X93BApgBZ/awmvVpKIkbi 7w24ZLEiPUtdG8LgcxWZv07xK4DF9iBU0iS9ohvq7/Hmje9EI/2zb1D/UPL5Eh2l/J7v XPWlAB55TCNr1iU50zV7KEotvd6vGuUjWn64oYiRMmBZJRGpn2Un5kbqgddAEWKOgcO/ 9j2FukEYRZcEiibv+LYeo7lL24RyKSWqeeprATry/HI+HYriq2yWBR/g9RQc/s2016kC rpIg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Yu/rTRBj"; 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 n3-20020a05620a294300b007757beeb5acsi8892685qkp.445.2023.11.20.04.08.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 04:08:11 -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="Yu/rTRBj"; 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 C1799386182C for ; Mon, 20 Nov 2023 12:08:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id CBA0A3860769 for ; Mon, 20 Nov 2023 12:07:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBA0A3860769 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 CBA0A3860769 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700482059; cv=none; b=KwrpbkIItA2jErX74HmiKQIaOfAKyJKY5YDBCQ9y4qATTDx2RnOnxRl9jZ1QXFvZMkFZY44eqiL9Y6ooXXtVz8dGHyA4mkBks1x8sHK2o7vohili5uUEParAzUuzkGOQh8R1ufpG3Dkwxuip9qtQf3MFEXjaniMFlCNtRos8sAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700482059; c=relaxed/simple; bh=OC6mDSE1mT5OARjETGIplcg+LoUqzO7tIr/9EMh2aCY=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=oJdbyvP91fXnGM9IwEHtsZfip8gHDYb9WIdP3MaIaJa/4aBSjwQ6t5F+d1ceZJrT6uXs7x0naZHPYHKwQqQHlU8y7NS1z9NwsV/90/flcSLQV5sPw0Zx2+QjNlY7YrQD/YeWO6nuFqEMluODrGq44rGKh84RKAUQ6uwJOOsrJH4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c83c0ad7e6so12268311fa.1 for ; Mon, 20 Nov 2023 04:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700482055; x=1701086855; 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=XWSaJJ/f8+1zQVVK8Gk1mrKZPYAA8REpQy73jsEi7HY=; b=Yu/rTRBjClTh7Pd9fT0Fhcc27dPN1JyBnsriQpxPQRTBCHpb/jduv35ryO/kJza52q 97Pxaf4koxQMGcAkOaoqKnENc04H4jR796mi97bTXlvJ8Kjn5q/OnDvSSTXzdOSm63po 15NFtSaDb9LLERap88Lz0oxlZwUccvvoNj8AvmIYCSzhBRVrUdw+z1H903uNWRHUIMyv GQlMzy2/2Y81KfsMEHU/XBdHekudclpcQBAYBLcmngYGgBMfC/yaRZBx514fGJK1I37s JX4HlXbjKy0HbQ3oP6EPdGVeIkz0nfTkoGJWiuGpZCBMRiBajMQ/CV9uAkqrn6qp0zTb AWkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700482055; x=1701086855; 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=XWSaJJ/f8+1zQVVK8Gk1mrKZPYAA8REpQy73jsEi7HY=; b=ayFMzFpEI6XFUK7rOtVgmRPNeyqhr22aVh5SJXMYyq5maWAUcr0KhyDVxcYmHcQg2x QXdaKMgSpfrJr5r90AolQIi/VxomwNqMYsk4jg0W5/4M39BGl2SpXV1NjJ2X9rJlm5v5 DqcI6YpoI9gMRIxqEIyfU+xtMJFa+ihTbWF0CsKu6SsAE/KZSbAMackV72LY4GBdN0dQ +jAKWHNNNY80NKNvmRHsmzF9c+sbtYEBYo8G950sM1cA6dtZWs91AbCAE+HwnD0NW2MW q1rhYWHbuKOVAOnH0bk//GacHeTu5GjLXuozXdX4bCb/3MdcPhDOqZL7a34PZSSITdFP LSRw== X-Gm-Message-State: AOJu0YwDhOwjQgO2O8KC8sQ5aYVB6c/UzRzBH0a1vJ2+9H2jAURs4z2d sgFKaiG4bkJBfu++6Qsa9K/PLORQN1vMauDoYKzF X-Received: by 2002:a05:651c:2048:b0:2c5:36e:31bf with SMTP id t8-20020a05651c204800b002c5036e31bfmr3589258ljo.5.1700482055425; Mon, 20 Nov 2023 04:07:35 -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 p22-20020a2ea4d6000000b002c50b040e94sm1045559ljm.85.2023.11.20.04.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 04:07:34 -0800 (PST) From: Maxim Kuvyrkov To: gcc-patches@gcc.gnu.org Cc: Maxim Kuvyrkov , Bernd Schmidt , Vladimir Makarov , Jeff Law Subject: [PATCH 1/1] sched-deps.cc (find_modifiable_mems): Avoid exponential behavior Date: Mon, 20 Nov 2023 12:06:49 +0000 Message-Id: <20231120120649.672893-2-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=-11.9 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 This patch avoids sched-deps.cc:find_inc() creating exponential number of dependencies, which become memory and compilation time hogs. Consider example (simplified from PR96388) ... === sp=sp-4 // sp_insnA mem_insnA1[sp+A1] ... mem_insnAN[sp+AN] sp=sp-4 // sp_insnB mem_insnB1[sp+B1] ... mem_insnBM[sp+BM] === ... in this example find_modifiable_mems() will arrange for mem_insnA* to be able to pass sp_insnA, and, while doing this, will create dependencies between all mem_insnA*s and sp_insnB -- because sp_insnB is a consumer of sp_insnA. After this sp_insnB will have N new backward dependencies. Then find_modifiable_mems() gets to mem_insnB*s and starts to create N new dependencies for _every_ mem_insnB*. This gets us N*M new dependencies. In PR96833's testcase N and M are 10k-15k, which causes RAM usage of 30GB and compilation time of 30 minutes, with sched2 accounting for 95% of both metrics. After this patch the RAM usage is down to 1GB and compilation time is down to 3-4 minutes, with sched2 no longer standing out on -ftime-report or memory usage. gcc/ChangeLog: PR rtl-optimization/96388 PR rtl-optimization/111554 * sched-deps.cc (find_inc): Avoid exponential behavior. --- gcc/sched-deps.cc | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index c23218890f3..397bb9fd462 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -4779,24 +4779,59 @@ parse_add_or_inc (struct mem_inc_info *mii, rtx_insn *insn, bool before_mem) /* Once a suitable mem reference has been found and the corresponding data in MII has been filled in, this function is called to find a suitable add or inc insn involving the register we found in the memory - reference. */ + reference. + If successful, this function will create additional dependencies between + - mii->inc_insn's producers and mii->mem_insn as a consumer (if backwards) + - mii->inc_insn's consumers and mii->mem_insn as a producer (if !backwards). +*/ static bool find_inc (struct mem_inc_info *mii, bool backwards) { sd_iterator_def sd_it; dep_t dep; + sd_list_types_def mem_deps = backwards ? SD_LIST_HARD_BACK : SD_LIST_FORW; + int n_mem_deps = sd_lists_size (mii->mem_insn, mem_deps); - sd_it = sd_iterator_start (mii->mem_insn, - backwards ? SD_LIST_HARD_BACK : SD_LIST_FORW); + sd_it = sd_iterator_start (mii->mem_insn, mem_deps); while (sd_iterator_cond (&sd_it, &dep)) { dep_node_t node = DEP_LINK_NODE (*sd_it.linkp); rtx_insn *pro = DEP_PRO (dep); rtx_insn *con = DEP_CON (dep); - rtx_insn *inc_cand = backwards ? pro : con; + rtx_insn *inc_cand; + int n_inc_deps; + + if (backwards) + { + inc_cand = pro; + n_inc_deps = sd_lists_size (inc_cand, SD_LIST_BACK); + } + else + { + inc_cand = con; + n_inc_deps = sd_lists_size (inc_cand, SD_LIST_FORW); + } + + /* In the FOR_EACH_DEP loop below we will create additional n_inc_deps + for mem_insn. This by itself is not a problem, since each mem_insn + will have only a few inc_insns associated with it. However, if + we consider that a single inc_insn may have a lot of mem_insns, AND, + on top of that, a few other inc_insns associated with it -- + those _other inc_insns_ will get (n_mem_deps * number of MEM insns) + dependencies created for them. This may cause an exponential + growth of memory usage and scheduling time. + See PR96388 for details. + We [heuristically] use n_inc_deps as a proxy for the number of MEM + insns, and drop opportunities for breaking modifiable_mem dependencies + when dependency lists grow beyond reasonable size. */ + if (n_mem_deps * n_inc_deps + >= param_max_pending_list_length * param_max_pending_list_length) + goto next; + if (DEP_NONREG (dep) || DEP_MULTIPLE (dep)) goto next; + if (parse_add_or_inc (mii, inc_cand, backwards)) { struct dep_replacement *desc; @@ -4838,6 +4873,8 @@ find_inc (struct mem_inc_info *mii, bool backwards) desc->insn = mii->mem_insn; move_dep_link (DEP_NODE_BACK (node), INSN_HARD_BACK_DEPS (con), INSN_SPEC_BACK_DEPS (con)); + + gcc_assert (mii->inc_insn == inc_cand); if (backwards) { FOR_EACH_DEP (mii->inc_insn, SD_LIST_BACK, sd_it, dep) From patchwork Wed Nov 22 11:14:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746015 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239630wru; Wed, 22 Nov 2023 03:15:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IELnnlwOMHHRQ8gFfeEtfDwR6AaQ375Iajg5/Jq22dIevCacF104beFRUCBBDYn4oioLoER X-Received: by 2002:a25:2315:0:b0:da0:6cf3:c629 with SMTP id j21-20020a252315000000b00da06cf3c629mr1409654ybj.41.1700651736655; Wed, 22 Nov 2023 03:15:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651736; cv=pass; d=google.com; s=arc-20160816; b=Dk18/odpjeA7VsSKAXjL/iLGoqZT9gYjWVW5CJfRBjE7UXLJJVtRpQr1wcZEWrW/x1 /zLKFHRNb56cAVUPDolUya7IZ4PW6oyTEsARmJN2gxMLDXvFKns92PTObDeeKFooYlZ9 KFxEh4fHIua8TcAGqgItcZXi7hHWJcpVG6Abyxt15va1UFIG7QGWWnEBSRQfKK2ync69 Bc0Z/g/e5HF37S6Lzf1TS2Wm5LKc/GOPWkNMCOycC6EgfA50bc8bw9r6DRMM8s01IKJg cFqeSBSqb7uiOk5eNDUQfdxwm5fx3Ipymlo9jmz/W4NvHSqPO/C8X1zFNiQROKM/wAS6 17+w== 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=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=AR505dGrgefjrIYgBWTafszPBqd+DbGCNTHYQvM38O3MiyurFevJQJx93a7JtVgAFh FZtWDhboRdlNOIQ3lWuJ7XI6zuxOD3lCqJAj5j6P6gGvnTMNHvItwKlCXWfWAi62a8Dh hJL1MrTjjUDwQHtmwo0+cdXeULzSp1nDt2WacQHusFcpkCu9+z7U9nielFgt6c6ceWt7 VMjuHAc0idxFC5y9VqtbNxTclTJMXGXD+PnBekUVpThDhaXi1yPkLNqM3ZJ6eQNFI5Sb Lh+PvDLBkvxK7CK3YeVU/iIo00hzM+ROwxOTPTEhDxzWK/0Oya12RLm8rNDy1CXI5VSA y+lg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dBNWPiMt; 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 e15-20020ad4418f000000b00679182534adsi8048278qvp.24.2023.11.22.03.15.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:15:36 -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=dBNWPiMt; 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 4DAEB3857000 for ; Wed, 22 Nov 2023 11:15:36 +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 2E59C3858C29 for ; Wed, 22 Nov 2023 11:14:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E59C3858C29 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 2E59C3858C29 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=1700651697; cv=none; b=IvaeGrXuBccXnFNP+I9/CXrjjw8E+T9lCUK6E6Rt5wEZTI83fLg7sPjSn50Kpjs2HB92p8wgoLOz24Tq7Pbr+iSH/4gYs9TBmJreuZ5sSKzN3sW6iH/ZctslQJ7KhBQOrwxnupumrYeDQYvEV5ufnsXyPNhKvGPwe0qthu4bCYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651697; c=relaxed/simple; bh=tJ8/NYU8qbcCJmVtHwz5nuWPB3jDMdZiJiwQGuB+NeA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tJGc+Y9OUQaltuKXEI2mVviQy1XuM0MYDKUvM92BhVpn6L52QJpYsTYLnF3zQhtvrgNHmR2ImMC5YgJTTo56g1+GVwgEde0hxAe94FEjCzj8pYLpBwNKVbAzNpBn4wECLRiNBzvKTDWM1DRvVaveuggY929SC5Bv9LJRI+vFh90= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637718e87.1 for ; Wed, 22 Nov 2023 03:14:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651692; x=1701256492; 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=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; b=dBNWPiMtS9saiCjEIF0aQcLPrK2jKJJwGpgjll1WjFqNdo8YB1IUP/J5/FajVuAsNQ iW1OhoX8rOA1OS+UdaXks28nEG6NQWHamTYTZq1xHTVzJ6RW/8dSo3RCbeuutcHCYlV9 v1mOQbEQQXbgItj9ea/np/plw4rPXh57YSVKIPcm4SrQjdYzKLad9mH0xUwaSNnAmHm+ UGbjz86JEMErrO+vQ+4a+6zUZYwvKCHYww44USsrXUn5Eui5OHhus/gd/h3z/H0HoiHt dX4eBPKeIcaeyxtWhfwMrD2vEUk9DH6DZqRYODq281gNroGEWw9PDBf9z3SgEAnHXJKO Ijkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651692; x=1701256492; 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=0dpmp0+82ieuy/6u/rtD3q28q5gN8tXahIG7ZMVwLB4=; b=Q7vDKi5Lfcb3U/gXFLVdU572iV4P5RcX7QUeVe+p2lVSfzc8CtUcxy3R53TdPCApkc CEBdSPgNLmsdByaJdZVzx4/Nn+fE5hLx1nLy+Sm7rA94i4MfyyPv+R5xZ6beIJfGaDL6 pOu1fAdstrWHxVdHWUpE91S723vkW2DyVMThl26OAdkw0kqklK3SmFTwZvYCfrbt9zTu POP02DohvaS54RitfGGhzGCJ12Ax7sGJeER8sNt2I/SRzINZZOZ0kT5X0A98KInAIsL7 twxN8MWMAQ7bYFdwLQbd8FswXgBCvUdohaKn0srEe3GbUvyl2t3A8brlWM1rAzvieVxq uGqA== X-Gm-Message-State: AOJu0YyC2WNJJ261g0plgderVsvDx2fQ6/43nV8E3ZBkzuke2ZwKIsv5 0qk6fF3Cfikpb0ahlhYv8+HhJv2Pjq6ggqVCd7iJ0jU= X-Received: by 2002:a05:6512:3daa:b0:509:b45:8879 with SMTP id k42-20020a0565123daa00b005090b458879mr1426297lfv.3.1700651691518; Wed, 22 Nov 2023 03:14:51 -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.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:50 -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 2/8] Unify implementations of print_hard_reg_set() Date: Wed, 22 Nov 2023 11:14:09 +0000 Message-Id: <20231122111415.815147-3-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=-11.9 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 We currently have 3 implementations of print_hard_reg_set() (all with the same name!) in ira-color.cc, ira-conflicts.cc, and sel-sched-dump.cc. This patch generalizes implementation in ira-color.cc, and uses it in all other places. The declaration is added to hard-reg-set.h. The motivation for this patch is the [upcoming] need for print_hard_reg_set() in sched-deps.cc. gcc/ChangeLog: * hard-reg-set.h (print_hard_reg_set): Declare. * ira-color.cc (print_hard_reg_set): Generalize a bit. (debug_hard_reg_set, print_hard_regs_subforest,) (setup_allocno_available_regs_num): Update. * ira-conflicts.cc (print_hard_reg_set): Remove. (print_allocno_conflicts): Use global print_hard_reg_set(). * sel-sched-dump.cc (print_hard_reg_set): Remove. (dump_hard_reg_set): Use global print_hard_reg_set(). * sel-sched-dump.h (dump_hard_reg_set): Mark as DEBUG_FUNCTION. --- gcc/hard-reg-set.h | 3 +++ gcc/ira-color.cc | 17 ++++++++++------- gcc/ira-conflicts.cc | 39 ++++----------------------------------- gcc/sel-sched-dump.cc | 21 ++++----------------- gcc/sel-sched-dump.h | 2 +- 5 files changed, 22 insertions(+), 60 deletions(-) diff --git a/gcc/hard-reg-set.h b/gcc/hard-reg-set.h index b0bb9bce074..81bca6df0e5 100644 --- a/gcc/hard-reg-set.h +++ b/gcc/hard-reg-set.h @@ -524,4 +524,7 @@ call_used_or_fixed_reg_p (unsigned int regno) } #endif +/* ira-color.cc */ +extern void print_hard_reg_set (FILE *, HARD_REG_SET, const char *, bool); + #endif /* ! GCC_HARD_REG_SET_H */ diff --git a/gcc/ira-color.cc b/gcc/ira-color.cc index f2e8ea34152..43564b44933 100644 --- a/gcc/ira-color.cc +++ b/gcc/ira-color.cc @@ -482,11 +482,14 @@ first_common_ancestor_node (allocno_hard_regs_node_t first, } /* Print hard reg set SET to F. */ -static void -print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p) +void +print_hard_reg_set (FILE *f, HARD_REG_SET set, + const char *title, bool new_line_p) { int i, start, end; + if (title) + fprintf (f, "%s", title); for (start = end = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++) { bool reg_included = TEST_HARD_REG_BIT (set, i); @@ -516,7 +519,7 @@ print_hard_reg_set (FILE *f, HARD_REG_SET set, bool new_line_p) DEBUG_FUNCTION void debug_hard_reg_set (HARD_REG_SET set) { - print_hard_reg_set (stderr, set, true); + print_hard_reg_set (stderr, set, NULL, true); } /* Print allocno hard register subforest given by ROOTS and its LEVEL @@ -534,7 +537,7 @@ print_hard_regs_subforest (FILE *f, allocno_hard_regs_node_t roots, for (i = 0; i < level * 2; i++) fprintf (f, " "); fprintf (f, "%d:(", node->preorder_num); - print_hard_reg_set (f, node->hard_regs->set, false); + print_hard_reg_set (f, node->hard_regs->set, NULL, false); fprintf (f, ")@%" PRId64"\n", node->hard_regs->cost); print_hard_regs_subforest (f, node->first, level + 1); } @@ -2982,12 +2985,12 @@ setup_allocno_available_regs_num (ira_allocno_t a) " Allocno a%dr%d of %s(%d) has %d avail. regs ", ALLOCNO_NUM (a), ALLOCNO_REGNO (a), reg_class_names[aclass], ira_class_hard_regs_num[aclass], n); - print_hard_reg_set (ira_dump_file, data->profitable_hard_regs, false); + print_hard_reg_set (ira_dump_file, data->profitable_hard_regs, NULL, false); fprintf (ira_dump_file, ", %snode: ", data->profitable_hard_regs == data->hard_regs_node->hard_regs->set ? "" : "^"); print_hard_reg_set (ira_dump_file, - data->hard_regs_node->hard_regs->set, false); + data->hard_regs_node->hard_regs->set, NULL, false); for (i = 0; i < nwords; i++) { ira_object_t obj = ALLOCNO_OBJECT (a, i); @@ -3000,7 +3003,7 @@ setup_allocno_available_regs_num (ira_allocno_t a) } fprintf (ira_dump_file, " (confl regs = "); print_hard_reg_set (ira_dump_file, OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), - false); + NULL, false); fprintf (ira_dump_file, ")"); } fprintf (ira_dump_file, "\n"); diff --git a/gcc/ira-conflicts.cc b/gcc/ira-conflicts.cc index a4d93c8d734..69806b1a15b 100644 --- a/gcc/ira-conflicts.cc +++ b/gcc/ira-conflicts.cc @@ -670,37 +670,6 @@ build_conflicts (void) -/* Print hard reg set SET with TITLE to FILE. */ -static void -print_hard_reg_set (FILE *file, const char *title, HARD_REG_SET set) -{ - int i, start, end; - - fputs (title, file); - for (start = end = -1, i = 0; i < FIRST_PSEUDO_REGISTER; i++) - { - bool reg_included = TEST_HARD_REG_BIT (set, i); - - if (reg_included) - { - if (start == -1) - start = i; - end = i; - } - if (start >= 0 && (!reg_included || i == FIRST_PSEUDO_REGISTER - 1)) - { - if (start == end) - fprintf (file, " %d", start); - else if (start == end + 1) - fprintf (file, " %d %d", start, end); - else - fprintf (file, " %d-%d", start, end); - start = -1; - } - } - putc ('\n', file); -} - static void print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a) { @@ -759,14 +728,14 @@ print_allocno_conflicts (FILE * file, bool reg_p, ira_allocno_t a) conflicting_hard_regs = (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj) & ~ira_no_alloc_regs & reg_class_contents[ALLOCNO_CLASS (a)]); - print_hard_reg_set (file, "\n;; total conflict hard regs:", - conflicting_hard_regs); + print_hard_reg_set (file, conflicting_hard_regs, + "\n;; total conflict hard regs:", true); conflicting_hard_regs = (OBJECT_CONFLICT_HARD_REGS (obj) & ~ira_no_alloc_regs & reg_class_contents[ALLOCNO_CLASS (a)]); - print_hard_reg_set (file, ";; conflict hard regs:", - conflicting_hard_regs); + print_hard_reg_set (file, conflicting_hard_regs, + ";; conflict hard regs:", true); putc ('\n', file); } diff --git a/gcc/sel-sched-dump.cc b/gcc/sel-sched-dump.cc index 05de9840937..5b2439cf4e2 100644 --- a/gcc/sel-sched-dump.cc +++ b/gcc/sel-sched-dump.cc @@ -535,26 +535,13 @@ dump_insn_vector (rtx_vec_t succs) sel_print ("NULL "); } -/* Dumps a hard reg set SET to FILE using PREFIX. */ -static void -print_hard_reg_set (FILE *file, const char *prefix, HARD_REG_SET set) -{ - int i; - - fprintf (file, "%s{ ", prefix); - for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) - { - if (TEST_HARD_REG_BIT (set, i)) - fprintf (file, "%d ", i); - } - fprintf (file, "}\n"); -} - /* Dumps a hard reg set SET using PREFIX. */ -void +DEBUG_FUNCTION void dump_hard_reg_set (const char *prefix, HARD_REG_SET set) { - print_hard_reg_set (sched_dump, prefix, set); + fprintf (sched_dump, "%s{", prefix); + print_hard_reg_set (sched_dump, set, NULL, false); + fprintf (sched_dump, "}\n"); } /* Pretty print INSN. This is used as a hook. */ diff --git a/gcc/sel-sched-dump.h b/gcc/sel-sched-dump.h index 2a207cefda2..e5095b2e986 100644 --- a/gcc/sel-sched-dump.h +++ b/gcc/sel-sched-dump.h @@ -214,7 +214,7 @@ extern void dump_av_set (av_set_t); extern void dump_lv_set (regset); extern void dump_blist (blist_t); extern void dump_flist (flist_t); -extern void dump_hard_reg_set (const char *, HARD_REG_SET); +DEBUG_FUNCTION extern void dump_hard_reg_set (const char *, HARD_REG_SET); extern void sel_debug_cfg_1 (int); extern void sel_debug_cfg (void); extern void setup_dump_cfg_params (void); From patchwork Wed Nov 22 11:14:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746018 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239831wru; Wed, 22 Nov 2023 03:16:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVyQM5tUszt96jlKsHrmcFs1jHZwdLRTxyI4kYb6tMP3mpmeMKa7s4JIOqTVZIdNNDD1xP X-Received: by 2002:a05:620a:839a:b0:767:2076:5bee with SMTP id pb26-20020a05620a839a00b0076720765beemr2042053qkn.9.1700651766356; Wed, 22 Nov 2023 03:16:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651766; cv=pass; d=google.com; s=arc-20160816; b=qwp6zzc8VW/z3Q6wegCskV4Mkc3jIu63dcYCBwMTnwYlMrzWZSWrV0hAq+HodA9wrY 2WlyLwtBMFvhs5ny6hC+P1DMsbUtuu/N6QK7+TN+3b7W087k2sadtOm3uSCjmFmHf6K1 OX4xEXWV3wCjOCEx4vVqaRrTaQT25MTzJ2OrID5/62AF/eCg0CyFWTrjllxK0G2VSAGI LWPxQi+y4ZGQJhDHtH9zhbgRsYHaZW7OqTY45Q5f1wU1QTcy2JVFLXGvephgi9fItYMW bEULqlK5Z4MqYXRPYN3HDyIEsS1k1iHPASspbvLZEzbMOrSXtTYkDK8PbgexoI3Nq9hJ 9I+g== 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=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=BvfCI4VJqG44br5dehknAPj4eJoBJiteLvh3KfojfYE6irIW7DLwWzizrlffsdP4gS OzorD+JenIqkV0ZT8hw/Z3O0loPHzzMqMXgbe1++MfkbaJjpafYfnBofmkrdEIShsXEl 83iHksgX9FJfwAoH8zVR6OCkxyuWbhX/h/jvuKA2I2lkdmeNh3hjAeUmYYGHROV8Mirc rkD9EwfEORc3vb6b3myi/a9QnrLgPAz5v3CS3fL27e4VkuiUDz7Sl5YNQ7uwKw2AI+5c mk+ZtMr/bLVWyz2Uheq5sLyEe+8LbIg5biNRa77mMpzY8KuaW0GaPxxWUGKpDFCznLiu /jIQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BSVNWMfF; 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 s13-20020a05620a080d00b0077a4af92713si10968784qks.565.2023.11.22.03.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:16:06 -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=BSVNWMfF; 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 05767385B504 for ; Wed, 22 Nov 2023 11:16:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id B51603858C35 for ; Wed, 22 Nov 2023 11:14:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B51603858C35 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 B51603858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651698; cv=none; b=ATcTpneyZYzBVDCKdW2+QMN7eABulVNa6AWFv/Fc303U3nifppoOxuI6ccO6wggQajSKmn6byXl6O6lMTOkdmTMNGBpB7sgt2i83wIMFGLCvr+8HfjUcRVQ9fNfBw5smJvUkkEEoJ26sARVc/1xdgnZycRjqYBzK7QPZpvjQTNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651698; c=relaxed/simple; bh=oU2Cpqf5iJjKqz6POqe2yKnidKee4m8qgaP9zrdGbS0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=auXHAuPHHlQDlUCfoUG0WzhMcRAjbG7ZFgXTmK3kYROF13NfUT/KMGkPxqwEcjx4Qi4VLk2729LV+x4Zly8gkIMMhfLePhw311Uq/lWNtzvdrAqb1drhedNb2Yo5brJeemMp+RexJ/3KUTLvsLLbjJ8L2SCs1+UqWBpJJi2q/eE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637727e87.1 for ; Wed, 22 Nov 2023 03:14:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651694; x=1701256494; 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=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; b=BSVNWMfFc6MFWQprQcRt4P/gLuiw4UuOYUm27w3YTlpp+r61Bz31NA9rHLJirauZYH jrr1UizFBLxZHY+LhM0nuyD38+xFXinSbZ68MuPbkK9s3SOlFh3JxpXDKASp+nhLosGI 9ykl5muttBMl6Cp1MFPuINejG5HKzFGhmu+2PqfwWmGJjkaWVx0lrAbux8jLtnQxumq+ SEOr3f8ZAiu9MtTEcwLVVaI+5imcLA5w1wK9lwU4Q3DlWkdBlAavPtayxpwmir2yHRLY 5COl8hpwgqe5bvRBv9zfwVcM9drC2yMCFpjxUilCmJazV5SPPieSqdPfClnfmjADdW7A 8mew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651694; x=1701256494; 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=H48D4rhsvzF21U15jkD1J8t5amr8dsgVPcanzs59YJ4=; b=QyfgmTVf05sWc8hEuQd8hkosLdOiNlMjuGX4OMlUlGEMN254OMseXxdMDWTgc4WQJQ EpjSl2vNtmKuQMwQ99m/RqUPQ47i9smqwukns5ooOAwc/11NI9DN4DBYW/FGLBAnUHIS 01ZqAacwjuakez3/FVm5u+Q7uBa3nvNhQCIk5lWQ+l7VtiwUjPmRWxM8N1IrP4LBzxTT +C0BlYWsWYHZpvBY7aiYRtjYEFuz2sn6gFeaANxb1bqHh4IxUIb4MTClMt3Jb3OuQfgy kb5iNy3vFshyFwcHKUVUyTEH+ZAFjqxycpgvDcgem9rOmHqYUswAZmzLe/BIqjCZ38TQ /BgA== X-Gm-Message-State: AOJu0YwggP/d4ZatM3DhsUMS0fGNc9cpYeI5V79PmozH3EAZl3ipEeTI tFq0GJaNpBj0CIe0DC6ZCOMCDRBL4a2akZcmGHjdwPs= X-Received: by 2002:a05:6512:2314:b0:507:9861:2be9 with SMTP id o20-20020a056512231400b0050798612be9mr1527173lfu.6.1700651694605; Wed, 22 Nov 2023 03:14:54 -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.14.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:52 -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 3/8] Simplify handling of INSN_ and EXPR_LISTs in sched-rgn.cc Date: Wed, 22 Nov 2023 11:14:10 +0000 Message-Id: <20231122111415.815147-4-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=-11.9 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 This patch simplifies logic behind deps_join(), which will be important for the upcoming improvements of sched-deps.cc logging. The only functional change is that when deps_join() is called with empty state for the 2nd argument, it will not reverse INSN_ and EXPR_LISTs in the 1st argument. Before this patch the lists were reversed due to use of concat_*_LIST(). Now, with copy_*_LIST() used for this case, the lists will remain in the original order. gcc/ChangeLog: * lists.cc (copy_EXPR_LIST, concat_EXPR_LIST): New functions. * rtl.h (copy_EXPR_LIST, concat_EXPR_LIST): Declare. * sched-rgn.cc (concat_insn_list, concat_expr_list): New helpers. (concat_insn_mem_list): Simplify. (deps_join): Update --- gcc/lists.cc | 30 +++++++++++++++++++++++++++- gcc/rtl.h | 4 +++- gcc/sched-rgn.cc | 51 +++++++++++++++++++++++++++--------------------- 3 files changed, 61 insertions(+), 24 deletions(-) diff --git a/gcc/lists.cc b/gcc/lists.cc index 2cdf37ad533..83e7bf32176 100644 --- a/gcc/lists.cc +++ b/gcc/lists.cc @@ -160,6 +160,24 @@ free_INSN_LIST_list (rtx_insn_list **listp) free_list ((rtx *)listp, &unused_insn_list); } +/* Make a copy of the EXPR_LIST list LINK and return it. */ +rtx_expr_list * +copy_EXPR_LIST (rtx_expr_list *link) +{ + rtx_expr_list *new_queue; + rtx_expr_list **pqueue = &new_queue; + + for (; link; link = link->next ()) + { + rtx x = link->element (); + rtx_expr_list *newlink = alloc_EXPR_LIST (REG_NOTE_KIND (link), x, NULL); + *pqueue = newlink; + pqueue = (rtx_expr_list **)&XEXP (newlink, 1); + } + *pqueue = NULL; + return new_queue; +} + /* Make a copy of the INSN_LIST list LINK and return it. */ rtx_insn_list * copy_INSN_LIST (rtx_insn_list *link) @@ -178,12 +196,22 @@ copy_INSN_LIST (rtx_insn_list *link) return new_queue; } +/* Duplicate the EXPR_LIST elements of COPY and prepend them to OLD. */ +rtx_expr_list * +concat_EXPR_LIST (rtx_expr_list *copy, rtx_expr_list *old) +{ + rtx_expr_list *new_rtx = old; + for (; copy; copy = copy->next ()) + new_rtx = alloc_EXPR_LIST (REG_NOTE_KIND (copy), copy->element (), new_rtx); + return new_rtx; +} + /* Duplicate the INSN_LIST elements of COPY and prepend them to OLD. */ rtx_insn_list * concat_INSN_LIST (rtx_insn_list *copy, rtx_insn_list *old) { rtx_insn_list *new_rtx = old; - for (; copy ; copy = copy->next ()) + for (; copy; copy = copy->next ()) { new_rtx = alloc_INSN_LIST (copy->insn (), new_rtx); PUT_REG_NOTE_KIND (new_rtx, REG_NOTE_KIND (copy)); diff --git a/gcc/rtl.h b/gcc/rtl.h index e4b6cc0dbb5..7e952d7cbeb 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3764,10 +3764,12 @@ extern void free_EXPR_LIST_list (rtx_expr_list **); extern void free_INSN_LIST_list (rtx_insn_list **); extern void free_EXPR_LIST_node (rtx); extern void free_INSN_LIST_node (rtx); +extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx); extern rtx_insn_list *alloc_INSN_LIST (rtx, rtx); +extern rtx_expr_list *copy_EXPR_LIST (rtx_expr_list *); extern rtx_insn_list *copy_INSN_LIST (rtx_insn_list *); +extern rtx_expr_list *concat_EXPR_LIST (rtx_expr_list *, rtx_expr_list *); extern rtx_insn_list *concat_INSN_LIST (rtx_insn_list *, rtx_insn_list *); -extern rtx_expr_list *alloc_EXPR_LIST (int, rtx, rtx); extern void remove_free_INSN_LIST_elem (rtx_insn *, rtx_insn_list **); extern rtx remove_list_elem (rtx, rtx *); extern rtx_insn *remove_free_INSN_LIST_node (rtx_insn_list **); diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc index e5964f54ead..da3ec0458ff 100644 --- a/gcc/sched-rgn.cc +++ b/gcc/sched-rgn.cc @@ -2585,25 +2585,32 @@ add_branch_dependences (rtx_insn *head, rtx_insn *tail) static class deps_desc *bb_deps; +/* Return a new insn_list with all the elements from the two input lists. */ +static rtx_insn_list * +concat_insn_list (rtx_insn_list *copy, rtx_insn_list *old) +{ + if (!old) + return copy_INSN_LIST (copy); + return concat_INSN_LIST (copy, old); +} + +/* Return a new expr_list with all the elements from the two input lists. */ +static rtx_expr_list * +concat_expr_list (rtx_expr_list *copy, rtx_expr_list *old) +{ + if (!old) + return copy_EXPR_LIST (copy); + return concat_EXPR_LIST (copy, old); +} + static void concat_insn_mem_list (rtx_insn_list *copy_insns, rtx_expr_list *copy_mems, rtx_insn_list **old_insns_p, rtx_expr_list **old_mems_p) { - rtx_insn_list *new_insns = *old_insns_p; - rtx_expr_list *new_mems = *old_mems_p; - - while (copy_insns) - { - new_insns = alloc_INSN_LIST (copy_insns->insn (), new_insns); - new_mems = alloc_EXPR_LIST (VOIDmode, copy_mems->element (), new_mems); - copy_insns = copy_insns->next (); - copy_mems = copy_mems->next (); - } - - *old_insns_p = new_insns; - *old_mems_p = new_mems; + *old_insns_p = concat_insn_list (copy_insns, *old_insns_p); + *old_mems_p = concat_expr_list (copy_mems, *old_mems_p); } /* Join PRED_DEPS to the SUCC_DEPS. */ @@ -2619,11 +2626,11 @@ deps_join (class deps_desc *succ_deps, class deps_desc *pred_deps) struct deps_reg *pred_rl = &pred_deps->reg_last[reg]; struct deps_reg *succ_rl = &succ_deps->reg_last[reg]; - succ_rl->uses = concat_INSN_LIST (pred_rl->uses, succ_rl->uses); - succ_rl->sets = concat_INSN_LIST (pred_rl->sets, succ_rl->sets); + succ_rl->uses = concat_insn_list (pred_rl->uses, succ_rl->uses); + succ_rl->sets = concat_insn_list (pred_rl->sets, succ_rl->sets); succ_rl->implicit_sets - = concat_INSN_LIST (pred_rl->implicit_sets, succ_rl->implicit_sets); - succ_rl->clobbers = concat_INSN_LIST (pred_rl->clobbers, + = concat_insn_list (pred_rl->implicit_sets, succ_rl->implicit_sets); + succ_rl->clobbers = concat_insn_list (pred_rl->clobbers, succ_rl->clobbers); succ_rl->uses_length += pred_rl->uses_length; succ_rl->clobbers_length += pred_rl->clobbers_length; @@ -2641,10 +2648,10 @@ deps_join (class deps_desc *succ_deps, class deps_desc *pred_deps) &succ_deps->pending_write_mems); succ_deps->pending_jump_insns - = concat_INSN_LIST (pred_deps->pending_jump_insns, + = concat_insn_list (pred_deps->pending_jump_insns, succ_deps->pending_jump_insns); succ_deps->last_pending_memory_flush - = concat_INSN_LIST (pred_deps->last_pending_memory_flush, + = concat_insn_list (pred_deps->last_pending_memory_flush, succ_deps->last_pending_memory_flush); succ_deps->pending_read_list_length += pred_deps->pending_read_list_length; @@ -2653,17 +2660,17 @@ deps_join (class deps_desc *succ_deps, class deps_desc *pred_deps) /* last_function_call is inherited by successor. */ succ_deps->last_function_call - = concat_INSN_LIST (pred_deps->last_function_call, + = concat_insn_list (pred_deps->last_function_call, succ_deps->last_function_call); /* last_function_call_may_noreturn is inherited by successor. */ succ_deps->last_function_call_may_noreturn - = concat_INSN_LIST (pred_deps->last_function_call_may_noreturn, + = concat_insn_list (pred_deps->last_function_call_may_noreturn, succ_deps->last_function_call_may_noreturn); /* sched_before_next_call is inherited by successor. */ succ_deps->sched_before_next_call - = concat_INSN_LIST (pred_deps->sched_before_next_call, + = concat_insn_list (pred_deps->sched_before_next_call, succ_deps->sched_before_next_call); } From patchwork Wed Nov 22 11:14:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746019 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp240180wru; Wed, 22 Nov 2023 03:17:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkbECSDqvLtRJ09J8u91K+TN8dgQS5UwigxiUhvGjiA3ze2h11CxthzhzRhJLq8qg4UjIP X-Received: by 2002:ac8:5c8b:0:b0:418:151a:5c0c with SMTP id r11-20020ac85c8b000000b00418151a5c0cmr8221725qta.11.1700651819917; Wed, 22 Nov 2023 03:16:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651819; cv=pass; d=google.com; s=arc-20160816; b=n8y/yiRhOeMdqCwW7MhVIxpoAf/SZAxpuma9JlS2bjRT8G+GXL29k4Jcp1n9jioLdx dK2hmwWgp7m9hWuE/udJN5eCUOnqIFg5Leie5s/kM+YosXP2yfHkUQICGhzNRUFuuwNO cw8yj2q+O+d/kZZDk2OSV00Ja/NfwHJzy621NERenfeaYdVnxnNsnbYOqzRheAt2rOh+ OqJFmcI7X4SXdl9HKtrnV5xZR8aDHSLHcjOh9MkIcusqvAAHRFpEW8uzVvNi5LPpO5k5 1Cbd1ZV/X1uzLdSAkN1De+6kTu0CqqBMxQkrri2rgzdMNSm84jPabj97IyVFYsdbeqga hBZA== 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=0pJajU2nlDrwysjZmlE0UjB/iuf4+ccwsz182IWPBLk=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=ErfNtVgMvuAlyc4F1DLVyzlxtOLQ9NBs6xbcQIEUv00qYi3McSfRAoco0E26lEvlbQ 4RIzi7/hfxlZm0lm8wSYkit6478sbKQ8QEOYZctAriCUdN+M3rrSVZhQLLt5sjSMkuIn Zb+uH6//KmMBwuln9DeGAtx4YWaPv+fS8+XkEKYrtF3KbhsnBU5FkdFzGq4fMllh96Uu IOLfKpZQRU6goFPG3yZusJI8COwuVw7EoJg+Bv+9/Ielhu/pw3XJfNfzJDF4AdwsZeQo BQGpmr9OPqSmEo0JMNuqIfaFzDEMrXwX3SaOVos3boEQWxa34gcoLefTSuumU4OVzfqW nSag== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YUyCSz+M; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id gx8-20020a05622a27c800b004236e210d43si3286565qtb.341.2023.11.22.03.16.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:16:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YUyCSz+M; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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 8D92F38582B1 for ; Wed, 22 Nov 2023 11:16:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 0B5B43858298 for ; Wed, 22 Nov 2023 11:14:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B5B43858298 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 0B5B43858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651700; cv=none; b=eJo5LR1BypH9UGybEdFgoCO9zxKPZYlP9cOE+36G8FGHSy5sG+eFD+7dpauTU2iPcQoKW6KRijimZmE0BMjSsYwFEkxfVfbmPhWSSp1WXlgA7wJa8ZGBv9kakeclRkcgsHCPntvzLGo9/JmCCGKWzp3YSajDtqdt8FpKJkwppig= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651700; c=relaxed/simple; bh=mLvJRuVEz55mWUIzvxvbz7oW00I+oG0vjq+zl3SOLGI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=xFTi2/F1c7ikVfrNc7HUKt1bMlScoW8pdQbfLCKPAP9w+xno0SvI6P9lr7eachqQVRuZQXAU325ipdWL/dWBa6296oHD214nHVjRQ4O+tVwNUXwsJTgZSR66wBEaIH3bPH+0Ua1fpwxxoYhOFh+yoyNNAHGcCe24hS/0U0fksaE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507a3af69d8so1802699e87.0 for ; Wed, 22 Nov 2023 03:14:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651697; x=1701256497; 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=0pJajU2nlDrwysjZmlE0UjB/iuf4+ccwsz182IWPBLk=; b=YUyCSz+MHgwMrDVXvfO9evcczxZpILvzRedrXWUdoZmCA65BZDlSbCj3gNrnsxQU0v Hnavy7GjpxOMmcB6P9JpZ5rKOGReC2ldR1r9XK2I3FB+MYXv888iXQVgt52X0ORhLE54 9+w9vZQ6wK9csKsNoc7fq+zH65Vd4EiYpNwiX21WMCnakPuxscx3Oi61mjMqCWly+Sf1 UOh/moaoAnF86bpz00EtFokYFfeoFIYW1qYnFL+uavuQnR4YLSMxFVqKUKj962Bcanu3 ZCvNmYCbht0ZfsOxRS7F8aJYRuB/ad23reZZ2npeaIImUb3uwHQMXWskUyLDpwIJSr/o 4CdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651697; x=1701256497; 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=0pJajU2nlDrwysjZmlE0UjB/iuf4+ccwsz182IWPBLk=; b=U856enlt+scadd2VP9a/5bADxim/9LPq02PjrbJHwEI3pUTfACHTD3nNo1z/EhNZiX 5JNeyYqAjZfn4xRYL4QqUccEUujViE/6FyMf9hbVdNFew6l/p041GKNNG7qJGl9I91dO dVETfIREG8l68bpo95SqdmY1T0SB1PHJ2E2X8UHmOBTKDvB0t2kJEbx9OPvKu7jd7hJ4 HfjkUu6IyDBZYu32LeIdEakJWskiZag3+VMu9jys13tV091iJ4ogLX+Cg8XncCocSuMj 2MbczrjuAIVx6adWEHR02+GAjK0VScp+vpkHoTlepN/+ohTa9v8TOsj9yoqFajOh2noE AzgQ== X-Gm-Message-State: AOJu0Yx0dV+BqU/nT7HbH3CvD/kx6NQaGzzk8vD7L4XR8hZPNPPwqJpi rMqhF9J2SeefNEQx6MArgOKvVjGKqd/rHWhWq3EgwNk= X-Received: by 2002:a05:6512:ba4:b0:509:4c65:f4cf with SMTP id b36-20020a0565120ba400b005094c65f4cfmr1465807lfv.0.1700651696705; Wed, 22 Nov 2023 03:14:56 -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.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:55 -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 4/8] Improve and fix sched-deps.cc: dump_dep() and dump_lists(). Date: Wed, 22 Nov 2023 11:14:11 +0000 Message-Id: <20231122111415.815147-5-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=-11.9 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 Better propagate flags from dump_lists() into dump_dep() and add a missing "]" in dump_lists(). gcc/ChangeLog: * sched-deps.cc (DUMP_DEP_PRO): Improve comment. (dump_dep_flags): Remove. (DUMP_LISTS_SIZE, DUMP_LISTS_DEPS, DUMP_LISTS_ALL): Continue numbering from DUMP_DEP_* flags. (dump_lists): Update and fix. --- gcc/sched-deps.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index 005fc0f567e..4d357079a7a 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -132,7 +132,8 @@ static void dump_ds (FILE *, ds_t); /* Define flags for dump_dep (). */ /* Dump producer of the dependence. */ -#define DUMP_DEP_PRO (2) +#define DUMP_DEP_PRO (2) /* Reserve "1" for handling of DUMP_DEP_ALL and + DUMP_LISTS_ALL. */ /* Dump consumer of the dependence. */ #define DUMP_DEP_CON (4) @@ -206,9 +207,6 @@ dump_dep (FILE *dump, dep_t dep, int flags) fprintf (dump, ">"); } -/* Default flags for dump_dep (). */ -static int dump_dep_flags = (DUMP_DEP_PRO | DUMP_DEP_CON); - /* Dump all fields of DEP to STDERR. */ void sd_debug_dep (dep_t dep) @@ -1454,19 +1452,20 @@ sd_delete_dep (sd_iterator_def sd_it) } /* Dump size of the lists. */ -#define DUMP_LISTS_SIZE (2) +#define DUMP_LISTS_SIZE (32) /* (DUMP_DEP_STATUS << 1) */ /* Dump dependencies of the lists. */ -#define DUMP_LISTS_DEPS (4) +#define DUMP_LISTS_DEPS (64) /* Dump all information about the lists. */ #define DUMP_LISTS_ALL (DUMP_LISTS_SIZE | DUMP_LISTS_DEPS) /* Dump deps_lists of INSN specified by TYPES to DUMP. - FLAGS is a bit mask specifying what information about the lists needs - to be printed. + FLAGS is a bit mask specifying what information about the lists and + the individual deps needs to be printed, this is a combination of + DUMP_DEP_* and DUMP_LISTS_* flags. If FLAGS has the very first bit set, then dump all information about - the lists and propagate this bit into the callee dump functions. */ + the lists and deps propagate this bit into the callee dump functions. */ static void dump_lists (FILE *dump, rtx insn, sd_list_types_def types, int flags) { @@ -1488,10 +1487,12 @@ dump_lists (FILE *dump, rtx insn, sd_list_types_def types, int flags) { FOR_EACH_DEP (insn, types, sd_it, dep) { - dump_dep (dump, dep, dump_dep_flags | all); + dump_dep (dump, dep, flags | all); fprintf (dump, " "); } } + + fprintf (dump, "]"); } /* Dump all information about deps_lists of INSN specified by TYPES From patchwork Wed Nov 22 11:14:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746014 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239584wru; Wed, 22 Nov 2023 03:15:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFELUCvWLIn5f7wMOJnEXAgUIOiFcJs30iIWAPu6Rv2jwB2a5UiaCDuFGisutwEi+tIbJPn X-Received: by 2002:a05:6870:2e0d:b0:1ea:69f6:fe09 with SMTP id oi13-20020a0568702e0d00b001ea69f6fe09mr2865591oab.10.1700651730125; Wed, 22 Nov 2023 03:15:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651730; cv=pass; d=google.com; s=arc-20160816; b=vMfn2M32pUuxPrJj3aU/OGF9z1tD/7mApl7iG94RHV2ZUUC8tTRHo6kh61Vl4bGtGo H+EcELuRpaiQmiYaRZks/kF6BQ0oLypM0Lk4TF9oOW3Th2eUxtFhlCgYXrp12/yQbBSh 7cahscl0WGohoUAbDsJrZFmF5d87qizOIVhzbCSL9H2XEl6rjyx2P6R3TRjG06yfYDyg gu5FwSYPbxrzV0X7tI3zhg5xQQaD5abs99zCJy3V0DR2zppfRIR29axZWLIiAp8eytEZ br0zZO6qqq6YJkgwRxgJQKvKvHY7X/fSwmVlFbnX7gKiiIjB8KrAiwjXbP1oUiabuvxl WL6w== 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=MgaXgJrGCc5F7WN/JQYmYB77xJsKJRxVjjf7y5/es7g=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=ka9dL1qjvkqrwDbAGPPvlV+IzdrwE9R/NGTC5eVTaPuJafY3XZunrZeL63IqjyVEgB LwH2rDrC5uCmDKArX9Rb18Z3T4V+tH5ZDJ8GuV9FAR9r6VXcQ2GKkjUh5HYylAQLvc+d u+5vga15Zs3sxt/dzIgEbXYXRIBMOFBd+sVsMlaSdM02ByM0zTiEfh8FJCpDVUTLAH3K c4vMDy5mbiCrrV7dCtkztaNkhUDaggvVYcA+JQWG9E9KrqyzDLsE6N/05PCVNwq45jQQ 0u2ggsplGfI5iT2TmqlPUw9NxTcJQqAX/ZngHgyHR31Ng8mpCqceMc4CyYfrMZbZ0Ykh MmfA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xDLv4MSp; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id k1-20020a05620a414100b007777245a946si11806018qko.41.2023.11.22.03.15.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:15:30 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xDLv4MSp; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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 C3A0A385B524 for ; Wed, 22 Nov 2023 11:15:29 +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 D0A083858035 for ; Wed, 22 Nov 2023 11:15:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0A083858035 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 D0A083858035 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=1700651702; cv=none; b=AaKU4yVkUORrTStjNCMaJooDhPCoXeDTBpC8fBJj6dUmYXK7OhFyLVTDLwq3iUXJPfOGpgyfBJirCKhUGjQS7crh0w/nDpC7VcLNPveSgXxC8qOn5TGaO6Ff5ew7rQP+7vpGpEkHXG3wH39OJ+l0J8ROWttsS7puN7ws9y8RwpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651702; c=relaxed/simple; bh=f2bkymAGt95H3BGKW8kjUB7EmPpwCxXU4Ok0yHXQ/q0=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=iEYvOE4mdlISi0pnzVMngWyzswFtqQH/2yLIaCtbrJDhzod7Lj9HFWw5VXo90uhYWjO2OOolWx1/vVZSrPyhl4sIs/be4UM2aRjS92soZas3obqeXWqI7P7eGIByY7ALuMSHBZJjjPOcg7T3sM9MIQXWpFVvP5pO2DTHntt56oY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50948640356so1871855e87.0 for ; Wed, 22 Nov 2023 03:15:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651699; x=1701256499; 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=MgaXgJrGCc5F7WN/JQYmYB77xJsKJRxVjjf7y5/es7g=; b=xDLv4MSpYGAFroMe5aNpj8/Hv1uSrhZkqE6N/xQyKM7bXnT46uXRu2jwbJnZ9mBXTb puXtrjTyqUii+9KOeeinCgnynkqtRLOdNxf8I3IUNyF9EZJMFO4cUTj81K87t7rEilrv pILnsZLDHOtsDfXO7Wdt3HMkaw/mHz8dPzJmH6sC1kpNbN7ZFmhcCb3/jyHt3SSHDw6+ pFZYuAhLIhMkRjDJgqIRftkObuEFDmBRPc8Lb2JFb3MPjMzPmXm1vQD7MRZmxTxnq2qr KZOFihj+1JD4z7oTHjODBQdhWKMQQYlgxhWedTv2R/Qswz9p/BJGOgsmbee/BTIYMVsT Ilzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651699; x=1701256499; 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=MgaXgJrGCc5F7WN/JQYmYB77xJsKJRxVjjf7y5/es7g=; b=VuH40Bw/heGyiaP/NKgIEZ+eiTkeVeluFKAxRVRFtLagMBL6IRH3nkAUnGioqHIBO4 O/2grLXgUxwXEqmAIoRCp1WpHLD3HZSFdkc2g7vlsiLHUHtckVBZCPxc553TZ9LaaWdb mFyoVQkA3AJvG/CeZ5d7NbYaoZc46DtDTV80URF+CM8EEJU1VKbWd5zUxw12g6Z3E+js jNRVgjKzvWmj06RCLtAkLjps1+U3UCGnyACXVEOEVGtPvecA+HamUes+O120ORzafSNh M7HSZP8JoCy5NdWwTVjdc65hHPcmarZe38ZoiH+SxayT1JNGykwkxBoegVlaSEXIsIIw nPIQ== X-Gm-Message-State: AOJu0YzGsyLxPgF3rjc6rGKd2cuU6LyLz2FVaeuq45q2aDqY9VGcFASK r94rLeH1EddtmYquvBgMrPbO0XnKJyCBBkn6HofOLVY= X-Received: by 2002:a05:6512:3e08:b0:503:3150:afbf with SMTP id i8-20020a0565123e0800b005033150afbfmr1435654lfv.4.1700651698886; Wed, 22 Nov 2023 03:14:58 -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.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:57 -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 5/8] Add a bit more logging scheduler's dependency analysis Date: Wed, 22 Nov 2023 11:14:12 +0000 Message-Id: <20231122111415.815147-6-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 gcc/ChangeLog: * sched-deps.cc (sd_add_dep, find_inc): Add logging about dependency creation. --- gcc/sched-deps.cc | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index 4d357079a7a..2a87158ba4b 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -1342,6 +1342,13 @@ sd_add_dep (dep_t dep, bool resolved_p) in the bitmap caches of dependency information. */ if (true_dependency_cache != NULL) set_dependency_caches (dep); + + if (sched_verbose >= 9) + { + fprintf (sched_dump, "created dependency "); + dump_dep (sched_dump, dep, 1); + fprintf (sched_dump, "\n"); + } } /* Add or update backward dependence between INSN and ELEM @@ -4879,18 +4886,33 @@ find_inc (struct mem_inc_info *mii, bool backwards) we create. */ gcc_assert (mii->inc_insn == inc_cand); + int n_deps_created = 0; if (backwards) { FOR_EACH_DEP (mii->inc_insn, SD_LIST_BACK, sd_it, dep) - add_dependence_1 (mii->mem_insn, DEP_PRO (dep), - REG_DEP_TRUE); + { + add_dependence_1 (mii->mem_insn, DEP_PRO (dep), + REG_DEP_TRUE); + ++n_deps_created; + } } else { FOR_EACH_DEP (mii->inc_insn, SD_LIST_FORW, sd_it, dep) - add_dependence_1 (DEP_CON (dep), mii->mem_insn, - REG_DEP_ANTI); + { + add_dependence_1 (DEP_CON (dep), mii->mem_insn, + REG_DEP_ANTI); + ++n_deps_created; + } } + if (sched_verbose >= 6) + fprintf (sched_dump, + "created %d deps for mem_insn %d due to " + "inc_insn %d %s deps\n", + n_deps_created, INSN_UID (mii->mem_insn), + INSN_UID (mii->inc_insn), + backwards ? "backward" : "forward"); + return true; } next: From patchwork Wed Nov 22 11:14:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746016 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239800wru; Wed, 22 Nov 2023 03:16:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5yVO1JWwbHW73j+O1WPc4Dd5FC5S+5mfhZjyVN9ilNI7Cvkha/akeaszRXrNs+csZfq0j X-Received: by 2002:a05:6808:124c:b0:3b5:66af:f8d6 with SMTP id o12-20020a056808124c00b003b566aff8d6mr2451814oiv.47.1700651760267; Wed, 22 Nov 2023 03:16:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651760; cv=pass; d=google.com; s=arc-20160816; b=tUO+xePHdg3JC01c+DjjGMgtuTia/ny3weiy8XH1eQSQ7gsk9l9lDo9OHWJUTq1NRi xpRpd5wIJsl4ddft1D/0nkU5kzjSTfFeGKxoOBhsMzFbbT/ZuPpk0FsFQDCAS/rs4Lk+ 0WeXnng/pjc9EgL6/W503+rJawQUgJo8GcSStSxAnryCus9F+0HObXrsNmCa1hcSvK+e vakGfC1VcOe2/Jb47yLa2wKuDKQZA81rU8GOO5X7Pcz3cVFhHGGSBbpYXbW1oFz7NsUI rV/q7/io+TXoj6vmTyai2wa6lTSRq/vxIKNRoAIjof7YO+efXm4ajPDu2fXSeIkgeVdQ sAug== 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=pCSVbEO/BeCpr3HmKemgKgCd7aACwKRmYYL8UJxMo/8=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=e0EACiZO7ZaE+VNrj/gdiqwr6cpOkpGNGH/FL2aYgeZzQSbG91893BIJWFqEKY5b3P QG24EHZAOtRcLUWK44UvIuOyBM5hq+bfICxzvO2BjVo3SyTF+qJ0VEEWfDf9+gUO+Scr lmYsSF7xwxc7wEyjJ+dIsdt5TKj4XGRkmUwcAeOqrV91ULDmM+svRX7uDo75FofQiL3I tIObMs0+2LJHD2fxVpAPzkFW5cmvtPFlYupUwLEaZo7RMPHo1A+83FgqtrLQjjyWrIGd jZagCn0FZ1fr0TgIwX12VCxJ7OAWE6yzZdc/bpBM4oRsdWc/40uIGhjkR72PY1NYWS7V PSQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b9lY4020; 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 c19-20020a05620a201300b0077435f2b668si10624226qka.207.2023.11.22.03.16.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:16:00 -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=b9lY4020; 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 98AC5385AC22 for ; Wed, 22 Nov 2023 11:15:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by sourceware.org (Postfix) with ESMTPS id 59A6038582A2 for ; Wed, 22 Nov 2023 11:15:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59A6038582A2 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 59A6038582A2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651705; cv=none; b=r8X6y8TOcEQ6ZW+dEfw01l0hkXRuflmH71Km6ENOD5CIW7uz24MV3XBH2Pfv953oLY7cpaq51gnyivNLxk/ENZxL09n74dXHTUoL9luO/Jo0LycWmlrvBEEray/ZOJzNjh6C7nHUASt3Vsnjwc/tIdZdc/XRfdp3QESfJw2c37U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651705; c=relaxed/simple; bh=5NP/NsqWSfRZ7KB1p2irswvHSP/cInbQ/1sqrEOvuEc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=tn8SJR8rPHxbtNeFSVIgK0pn3xg7j3g0FK8vQc0R2A+YPPoezkkRTl23rp6hg065st/p036mUhVHIcTh+NJNtAQt3WRyNrJCNhUt7W6yMH46PW1JojLfHJv6sBTIuh1KjeONDGSL1SUzClL8kpx7rw1NDMVTPu6sOS3K/xVyhP4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637766e87.1 for ; Wed, 22 Nov 2023 03:15:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651701; x=1701256501; 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=pCSVbEO/BeCpr3HmKemgKgCd7aACwKRmYYL8UJxMo/8=; b=b9lY4020zflQb4M/m/fvAxqrNtis13svSSQzsWlgdZcx50Gh+SaUlX8+SMZqskj1qj C4MwO65QV/yUlt9AKnADdtpF82GQ4dUWa26EGw5ioLVBlAOt0koRhcD7fWGKUfxNNBey rjAI1xnd8WW2l3nFdHXtt3PohsdDeqlFXAcK1S+8gOx/DfKO9Xxn5FajbmxdjRLJ6PqK K3KxO0/9fVXWdK5TuX+0ngIb5MUj+UdWr3YlNiydhuMUmPcQezmkkrTeFDuB9/jPXL54 PQpjcpXrYMyIGuA/R9yd4DbzxAfC9ouDdf3BLZk7sOgGylkwtMeBmmZ1HQGhuCfBS2M7 yyJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651701; x=1701256501; 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=pCSVbEO/BeCpr3HmKemgKgCd7aACwKRmYYL8UJxMo/8=; b=wiw+gjkQRujs1SgNjfvtzpLja/wJpw5l4H5+zh0w3id0Pf4W1TBtI+kluuSn5TeQXA qiikt0lSwC7v3G9PxpnAPjLMcYzahkpA2PlOh142GwsbYvq7+Fokvgaod/c8wh+aSpnT 0joG8yQN9i3bNBrVpqzR2nOezDc0ck0o9hKWg8itPshc/NxIgBTVhn3Z8a7gOUKfgWwJ W2at91ZXIOHX4J2TdSri76Zpdlv8tHkN+7jnMqGNvRFqKhZ/nb632XwWSYbV1fEzJso+ R/hJqBtZ/0ezR/DcEZbU9wObfLCHiUwoXTAmBSiXm7UiYDs9xssR7GQsdkBu911PQ2nC 8oEw== X-Gm-Message-State: AOJu0YyFsRp1Jufje4nvGTsbQgoMjIcovMkbVXMZkWvBRfyBhezR7WOV x7N0L34ySoikqzc1ZiYnSs3c6Htfx3DbzAkFunWCM9I= X-Received: by 2002:a05:6512:485b:b0:50a:7806:d0db with SMTP id ep27-20020a056512485b00b0050a7806d0dbmr1010887lfb.4.1700651701254; Wed, 22 Nov 2023 03:15:01 -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.14.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:14:59 -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 6/8] sched_deps.cc: Simplify initialization of dependency contexts Date: Wed, 22 Nov 2023 11:14:13 +0000 Message-Id: <20231122111415.815147-7-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 gcc/ChangeLog: * sched-deps.cc (init_deps, init_deps_reg_last): Simplify. (free_deps): Remove useless code. --- gcc/sched-deps.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index 2a87158ba4b..e0d3c97d935 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -3927,10 +3927,9 @@ init_deps (class deps_desc *deps, bool lazy_reg_last) int max_reg = (reload_completed ? FIRST_PSEUDO_REGISTER : max_reg_num ()); deps->max_reg = max_reg; - if (lazy_reg_last) - deps->reg_last = NULL; - else - deps->reg_last = XCNEWVEC (struct deps_reg, max_reg); + deps->reg_last = NULL; + if (!lazy_reg_last) + init_deps_reg_last (deps); INIT_REG_SET (&deps->reg_last_in_use); deps->pending_read_insns = 0; @@ -3961,9 +3960,7 @@ init_deps (class deps_desc *deps, bool lazy_reg_last) void init_deps_reg_last (class deps_desc *deps) { - gcc_assert (deps && deps->max_reg > 0); - gcc_assert (deps->reg_last == NULL); - + gcc_assert (deps && deps->max_reg > 0 && deps->reg_last == NULL); deps->reg_last = XCNEWVEC (struct deps_reg, deps->max_reg); } @@ -4013,8 +4010,6 @@ free_deps (class deps_desc *deps) it at all. */ free (deps->reg_last); deps->reg_last = NULL; - - deps = NULL; } /* Remove INSN from dependence contexts DEPS. */ 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); From patchwork Wed Nov 22 11:14:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Kuvyrkov X-Patchwork-Id: 746017 Delivered-To: patch@linaro.org Received: by 2002:a5d:6706:0:b0:32d:baff:b0ca with SMTP id o6csp239826wru; Wed, 22 Nov 2023 03:16:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKzK04B1AU4XZdzER8QgeFOVKLcb0UKGZWrx04LM0YbXaTnQHl4EkfEg0KVUk7z1YB7u7u X-Received: by 2002:a05:6358:5284:b0:168:dd37:172d with SMTP id g4-20020a056358528400b00168dd37172dmr2050979rwa.20.1700651765206; Wed, 22 Nov 2023 03:16:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700651765; cv=pass; d=google.com; s=arc-20160816; b=gejRSiiqAU2l62EDhiDjuQs26bgwxogrzwZ6mXVacbRyXV0bGhBQ8bntowtlmzxO2E 1BeG5/JKu5CcQ48n79VLC9BZt8cUwagoTvqdz1KURIqGsIeWoqCbRf7VTlQsy19TdWKi uleZcCCW8D6WjyVRECRspQq+eyV+lL3rPRw6e90Mw2IRKmUcN1ftsSx2Cw3TkkJ/n/G4 efNG/ow822k2HsVVY6xq2B3tdWU+GTh6+ajLadkOm0FxUZsD9S4BwhCViGogGGifkyLw S1a52XngNjGu48DaE5LRN6xPrg17WWfwFJBCwVvYqmvCN8nVBYRNME2A9Z3g7n3xh2ES J0Kw== 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=/2q13E4r51XZH8OiSadDqo+qaM2cMIFU1eeD/lDAAXg=; fh=WFm8hI3He6vfed9bNVx/Tt8MS1NEGxq9c34GiEnOLuU=; b=ZRBF1k/ooIs/FSL3KJJyPX/50i9zQ8+1VW1/ieqOFK7gpT24k1luKKhdHH1wNDXp4B KHstQfM9doVxe9LQS0f3vQXPEXqC8pyOHIPJzWXsJNEhvp9mZlIKjquGlpSaWbb/EF4g /MpDkhTtDnyHjjpkC6tyM2fSsKH93YKAgxdggLRCRL2rUX5I62QqsBUtQzcjMqoKJkPo TdoYyYSYrqd9/YxQZJdhrA4p8sq4PkAKbvOk8gvceozQyfaiKOUlTx8pj3tr3JYFaPM7 Z/+aCV6/ZMb+CJkxUpEDPDFSphTMA08pFtwUlquChX4oODxNVKVTtSw3l+EDLDdINHoz EGjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tqYTBMva; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id f2-20020a05620a280200b00773fe581c18si11721413qkp.463.2023.11.22.03.16.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:16:05 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tqYTBMva; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+patch=linaro.org@gcc.gnu.org designates 8.43.85.97 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 C8F1D385C422 for ; Wed, 22 Nov 2023 11:16:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by sourceware.org (Postfix) with ESMTPS id 1835C3857C60 for ; Wed, 22 Nov 2023 11:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1835C3857C60 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 1835C3857C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651718; cv=none; b=jG8IQJ1qsne23OC81LHFI834/1gM3jRFySVKK5a52UtncZ+lv4ADE+UENLw2M3cdMM8L96qNgq62BqwJAT248W1JG1i0M6c6BVWcV46AJWd/uYg42M7aVtB0i5B0Dy6UUyX6lvhL2WPwvh4BlrR/V2HHNWx33PMDyHbFZOEhick= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700651718; c=relaxed/simple; bh=nWpaDlOUd5tc0pQp/oeSeTfPwMPXerVZazc930uQSzA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=qqQbt9Fdxd+0D3QqxxshWTf8yCXuPboLWhqq8gdiYqD26RbT4A3dsZsIsIsrVnWJN/sPrNa/o28DNfqdT5EZYbkGG7KgNLlO6tMZSX6azjpk118cw0668vxS6wZwaqBtdgFCpgQjNqtsWDaOAJheaCF3H5aGVY0SlBD+5WIuXEM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507f63fcbf6so1637795e87.1 for ; Wed, 22 Nov 2023 03:15:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700651706; x=1701256506; 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=/2q13E4r51XZH8OiSadDqo+qaM2cMIFU1eeD/lDAAXg=; b=tqYTBMva+XkMDd6m8Ocpwkoah2QjcJdyZAUuKdjz4ILIDH/Y2ud1UUeaLND/97N9cc kLssCcV/5dyA6r+9N+PpEuqlBHkh/7Ci3xX0rUUBu+RiBRTqn6rdfiI13Sy6Z4mpFiLY kzglIANsWgvJyTH8yYOPlNBh3yGPZAzKQxujtOaAtEcDO2iCE1fXYpf7OtZfJUgVez3d e9GwWg/LjUEuZfvqBcaEeb97z0S0H1N+lkUOz94KqetIeeANU1Xb/f/w/m33bK7CirzF bEQRHjO4N+1j4TXLXOPU/oFayHpFG4IItAWvYq7R2CluVKKBy6/PIBw+4loBfMF+pZUb nNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700651706; x=1701256506; 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=/2q13E4r51XZH8OiSadDqo+qaM2cMIFU1eeD/lDAAXg=; b=Ww+ofovkdqjkkQtwO9y5gIAGBQvy7X59SygKoXv1cbNXOu4vmSLa5KljE9ZfxjUeP/ OfXc+Fn9MKuofSNz+C5/q9dHimOEJXljPZY5Nc1pBwNIt13+MTsIwKKeOofcUzZXC+lm nz5/UkrKAHKYeeV7gkTz3DyMnFJGlwIYsX0Fdsd7gRw/MRj1yNKpDMawcIgS3IuRaWiI pcLIF/1FuOpaj/4/Q2fLe7W/hGzuoSi+34vU9Sun7jSwZzcI+5X+2SiHoQ6rr9rgvNlN PA3BTLDfZAZKgQUlZIPnvs1EyLTfKBE5ioqcJfu7osm4r76DYX9cmQdQ5mDTSjpZ+bnL TvQQ== X-Gm-Message-State: AOJu0YyV5e0aAVkplltbYPu5CIK6JX7syHnP7+wvZBE+U/XjV3OnCQK3 3sO3yepFx1sLq4kGuVxl6xiUYe8ordEECsApLW2JQkU= X-Received: by 2002:a05:6512:3b22:b0:507:9d5c:62e3 with SMTP id f34-20020a0565123b2200b005079d5c62e3mr1412200lfv.5.1700651705736; Wed, 22 Nov 2023 03:15:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:15:04 -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 8/8] Improve logging of scheduler dependency analysis context Date: Wed, 22 Nov 2023 11:14:15 +0000 Message-Id: <20231122111415.815147-9-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 (2). Dependency analysis contexts (aka deps_desc objects) are huge, but each instruction affects only a small amount of data in these objects. Therefore, it is most useful to dump differential information compared to the dependency state after previous instruction. gcc/ChangeLog: * sched-deps.cc (reset_deps, dump_rtx_insn_list) (rtx_insn_list_same_p): New helper functions. (dump_deps_desc_diff): New function to dump dependency information. (sched_analysis_prev_deps): New static variable. (sched_analyze_insn): Dump dependency information. (init_deps_global, finish_deps_global): Handle sched_analysis_prev_deps. * sched-int.h (struct deps_reg): Update comments. * sched-rgn.cc (concat_insn_list, concat_expr_list): Update comments. --- gcc/sched-deps.cc | 197 ++++++++++++++++++++++++++++++++++++++++++++++ gcc/sched-int.h | 9 ++- gcc/sched-rgn.cc | 5 ++ 3 files changed, 210 insertions(+), 1 deletion(-) diff --git a/gcc/sched-deps.cc b/gcc/sched-deps.cc index f9290c82fd2..edca9927e23 100644 --- a/gcc/sched-deps.cc +++ b/gcc/sched-deps.cc @@ -1677,6 +1677,15 @@ delete_all_dependences (rtx_insn *insn) sd_delete_dep (sd_it); } +/* Re-initialize existing dependency context DEPS to be a copy of FROM. */ +static void +reset_deps (class deps_desc *deps, class deps_desc *from) +{ + free_deps (deps); + init_deps (deps, false); + deps_join (deps, from); +} + /* All insns in a scheduling group except the first should only have dependencies on the previous insn in the group. So we find the first instruction in the scheduling group by walking the dependence @@ -2960,6 +2969,177 @@ dump_reg_pending_data (FILE *file, rtx_insn *insn) } } +/* Dump rtx_insn_list LIST. + Consider moving to lists.cc if there are users outside of sched-deps.cc. */ +static void +dump_rtx_insn_list (FILE *file, rtx_insn_list *list) +{ + for (; list; list = list->next ()) + fprintf (file, " %d", INSN_UID (list->insn ())); +} + +/* Return TRUE if lists A and B have same elements in the same order. */ +static bool +rtx_insn_list_same_p (rtx_insn_list *a, rtx_insn_list *b) +{ + for (; a && b; a = a->next (), b = b->next ()) + if (a->insn () != b->insn ()) + return false; + + if (a || b) + return false; + + return true; +} + +/* Dump parts of DEPS that are different from PREV. + Dumping all information from dependency context produces huge + hard-to-analize logs; differential dumping is way more managable. */ +static void +dump_deps_desc_diff (FILE *file, class deps_desc *deps, class deps_desc *prev) +{ + /* Each "paragraph" is a single line of output. */ + + /* Note on param_max_pending_list_length: + During normal dependency analysis various lists should not exceed this + limit. Searching for "!!!" in scheduler logs can point to potential bugs + or poorly-handled corner-cases. */ + + if (!rtx_insn_list_same_p (deps->pending_read_insns, + prev->pending_read_insns)) + { + fprintf (file, ";; deps pending mem reads length(%d):", + deps->pending_read_list_length); + if ((deps->pending_read_list_length + deps->pending_write_list_length) + >= param_max_pending_list_length) + fprintf (file, "%d insns!!!", deps->pending_read_list_length); + else + dump_rtx_insn_list (file, deps->pending_read_insns); + fprintf (file, "\n"); + } + + if (!rtx_insn_list_same_p (deps->pending_write_insns, + prev->pending_write_insns)) + { + fprintf (file, ";; deps pending mem writes length(%d):", + deps->pending_write_list_length); + if ((deps->pending_read_list_length + deps->pending_write_list_length) + >= param_max_pending_list_length) + fprintf (file, "%d insns!!!", deps->pending_write_list_length); + else + dump_rtx_insn_list (file, deps->pending_write_insns); + fprintf (file, "\n"); + } + + if (!rtx_insn_list_same_p (deps->pending_jump_insns, + prev->pending_jump_insns)) + { + fprintf (file, ";; deps pending jump length(%d):", + deps->pending_flush_length); + if (deps->pending_flush_length >= param_max_pending_list_length) + fprintf (file, "%d insns!!!", deps->pending_flush_length); + else + dump_rtx_insn_list (file, deps->pending_jump_insns); + fprintf (file, "\n"); + } + + fprintf (file, ";; last"); + if (!rtx_insn_list_same_p (deps->last_pending_memory_flush, + prev->last_pending_memory_flush)) + { + fprintf (file, " memory_flush("); + dump_rtx_insn_list (file, deps->last_pending_memory_flush); + fprintf (file, ")"); + } + if (!rtx_insn_list_same_p (deps->last_function_call, + prev->last_function_call)) + { + fprintf (file, " call("); + dump_rtx_insn_list (file, deps->last_function_call); + fprintf (file, ")"); + } + if (!rtx_insn_list_same_p (deps->last_function_call_may_noreturn, + prev->last_function_call_may_noreturn)) + { + fprintf (file, " noreturn("); + dump_rtx_insn_list (file, deps->last_function_call_may_noreturn); + fprintf (file, ")"); + } + fprintf (file, "\n"); + + fprintf (file, ";; sched_before_next"); + if (!rtx_insn_list_same_p (deps->sched_before_next_call, + prev->sched_before_next_call)) + { + fprintf (file, " call("); + dump_rtx_insn_list (file, deps->sched_before_next_call); + fprintf (file, ")"); + } + if (!rtx_insn_list_same_p (deps->sched_before_next_jump, + prev->sched_before_next_jump)) + { + fprintf (file, " jump("); + dump_rtx_insn_list (file, deps->sched_before_next_jump); + fprintf (file, ")"); + } + fprintf (file, " in_post_call_group_p(%d)\n", deps->in_post_call_group_p); + + fprintf (file, ";; last_debug_insn(%d) last_args_size(%d) last_prologue(", + deps->last_debug_insn ? INSN_UID (deps->last_debug_insn) : -1, + deps->last_args_size ? INSN_UID (deps->last_args_size) : -1); + dump_rtx_insn_list (file, deps->last_prologue); + fprintf (file, ") last_epilogue("); + dump_rtx_insn_list (file, deps->last_epilogue); + fprintf (file, ") last_logue_was_epilogue(%d)\n", + deps->last_logue_was_epilogue); + + int i; + + gcc_assert (deps->max_reg == prev->max_reg); + for (i = 0; i < deps->max_reg; ++i) + { + struct deps_reg *reg_last = &deps->reg_last[i]; + struct deps_reg *reg_prev = &prev->reg_last[i]; + + if (rtx_insn_list_same_p (reg_last->uses, reg_prev->uses) + && rtx_insn_list_same_p (reg_last->sets, reg_prev->sets) + && rtx_insn_list_same_p (reg_last->implicit_sets, + reg_prev->implicit_sets) + && rtx_insn_list_same_p (reg_last->control_uses, + reg_prev->control_uses) + && rtx_insn_list_same_p (reg_last->clobbers, + reg_prev->clobbers)) + continue; + + fprintf (file, ";; reg %u: uses(", i); + if (reg_last->uses_length >= param_max_pending_list_length) + fprintf (file, "%d insns!!!", reg_last->uses_length); + else + dump_rtx_insn_list (file, reg_last->uses); + if (reg_last->clobbers_length >= param_max_pending_list_length) + { + fprintf (file, ") clobbers("); + fprintf (file, "%d insns!!!", reg_last->clobbers_length); + } + else + { + fprintf (file, ") sets("); + dump_rtx_insn_list (file, reg_last->sets); + fprintf (file, ") implicit_sets("); + dump_rtx_insn_list (file, reg_last->implicit_sets); + fprintf (file, ") control_uses("); + dump_rtx_insn_list (file, reg_last->control_uses); + fprintf (file, ") clobbers("); + dump_rtx_insn_list (file, reg_last->clobbers); + } + fprintf (file, ")\n"); + } +} + +/* Dependency analysis state before current insn. + Used by dump_deps_desc_diff(). */ +static class deps_desc *sched_analysis_prev_deps; + /* 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, @@ -3627,6 +3807,16 @@ sched_analyze_insn (class deps_desc *deps, rtx x, rtx_insn *insn) deps->last_logue_was_epilogue = true; } } + + if (sched_verbose >= 8) + { + dump_deps_desc_diff (sched_dump, deps, sched_analysis_prev_deps); + reset_deps (sched_analysis_prev_deps, deps); + fprintf (sched_dump, ";; "); + dump_lists (sched_dump, insn, SD_LIST_BACK, + DUMP_LISTS_ALL | DUMP_DEP_PRO); + fprintf (sched_dump, "\n"); + } } /* Return TRUE if INSN might not always return normally (e.g. call exit, @@ -4305,6 +4495,9 @@ init_deps_global (void) sched_deps_info->note_mem_dep = haifa_note_mem_dep; sched_deps_info->note_dep = haifa_note_dep; } + + sched_analysis_prev_deps = XNEW (class deps_desc); + init_deps (sched_analysis_prev_deps, false); } /* Free everything used by the dependency analysis code. */ @@ -4316,6 +4509,10 @@ finish_deps_global (void) FREE_REG_SET (reg_pending_clobbers); FREE_REG_SET (reg_pending_uses); FREE_REG_SET (reg_pending_control_uses); + + free_deps (sched_analysis_prev_deps); + free (sched_analysis_prev_deps); + sched_analysis_prev_deps = NULL; } /* Estimate the weakness of dependence between MEM1 and MEM2. */ diff --git a/gcc/sched-int.h b/gcc/sched-int.h index 64a2f0bcff9..8a3109ce86e 100644 --- a/gcc/sched-int.h +++ b/gcc/sched-int.h @@ -455,7 +455,9 @@ struct deps_reg int clobbers_length; }; -/* Describe state of dependencies used during sched_analyze phase. */ +/* Describe state of dependencies used during sched_analyze phase. + Please consider updating sched-deps.cc:dump_deps_desc_diff() when adding + new fields. */ class deps_desc { public: @@ -499,6 +501,11 @@ public: large lists. */ int pending_flush_length; + /* Below are lists (and not just a single instructions) to allow inter-block + dependency analysis. Each block + may add a single insn to below lists, but when merging dependency + analysis context from multiple predecessor blocks, we may get a list. */ + /* The last insn upon which all memory references must depend. This is an insn which flushed the pending lists, creating a dependency between it and all previously pending memory references. This creates diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc index da3ec0458ff..72f0a2de66e 100644 --- a/gcc/sched-rgn.cc +++ b/gcc/sched-rgn.cc @@ -2590,6 +2590,10 @@ static rtx_insn_list * concat_insn_list (rtx_insn_list *copy, rtx_insn_list *old) { if (!old) + /* concat_*_LIST() will return a reversed copy of COPY. Working with + reversed copies would complicate dependency dumping in + dump_deps_desc_diff(), which internally uses reset_deps() and + deps_join(). Therefore, use copy_INSN_LIST() when OLD is NULL. */ return copy_INSN_LIST (copy); return concat_INSN_LIST (copy, old); } @@ -2599,6 +2603,7 @@ static rtx_expr_list * concat_expr_list (rtx_expr_list *copy, rtx_expr_list *old) { if (!old) + /* See comment in concat_insn_list() above. */ return copy_EXPR_LIST (copy); return concat_EXPR_LIST (copy, old); }