From patchwork Fri Jan 26 08:16:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 192425 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:e09d:b0:103:945f:af90 with SMTP id gm29csp515965dyb; Fri, 26 Jan 2024 00:18:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8HE1AnVdvckMYFZgifDTmICYnOZBWm9w4ExL7t0pmjrnwTGC5+Y7BFdKCDad9BLFvYEDV X-Received: by 2002:a05:6102:5f43:b0:46b:223c:8064 with SMTP id il3-20020a0561025f4300b0046b223c8064mr696043vsb.15.1706257080625; Fri, 26 Jan 2024 00:18:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706257080; cv=pass; d=google.com; s=arc-20160816; b=KYTLlcyYsJHajr17rgvcuFihAG314wfQwJIoHw/tjAw1V+JmCKQp5jCG1HYWN3ZkjQ LzLHwZ58akj8+Wu4jQ1XQsn0+LF6sGXo+JT1OQRTRKM2olf/CzWhLcVtXRaGbjhKNIDV 2O+3FNAjw3mdQSMnJesp+D8JlCE2Zrqj6TDP+EhrZDQssWG9pG/U/bfkdCYPE9QgRBB9 HGahO7PZSJ2sKYgeGdcjwTMqv7+LruKZKx/HUfw/ygJ/Xa2QxChT1DxiDftT8h9KSO4H gHW0n3G3wWSor350szpaFy/IZoS+P9XBWj4o++yeCax6hqZhfb0byXiKyR2ccgKIC0gX hnfA== 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 :subject:from:to:content-language:cc:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=3s55RcyL8iW2L0B8qQcSAMEwdEBJTroNXaJY85/R46E=; fh=wz/Ayr9eawIKebk4xZF1EDJaMc0kZyU+1RWF7TqU/dE=; b=UL/LdiyGifypxFVruYfKtgGP/Z9JwhaTL9U3XwHIXDHgRIPKxkSoKiPkNctKyTNRAp JPh3IjiVQtHK9IZLg5/q2S6s/LymG9gIEj0CSntV6rtH5rLCr+UGI2LIufxSnRvvx2X8 toWzOpTE5XUzYYzYrGv2WvSNrZKo3pxUOKZ0KJJWlLxpOGcpgPUxr+DkkrFEST/ndzyi Rnf+6huo+q1LR3FDcf77lVfg8WRagvKfEW3AHnU1JZPJP2TvAkFIY5lKz3R4+lV1Qqde w6+/iOsJNnMPe4cKlaX33bOcAM/qYDW668aucIHdBMSRGuxesDCD/LumFrQqZhFRBm8d 05Kw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SMw2u11w; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jv5-20020a05621429e500b0067f2c4029easi784299qvb.476.2024.01.26.00.18.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 00:18:00 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@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=@gmail.com header.s=20230601 header.b=SMw2u11w; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 512D238582B4 for ; Fri, 26 Jan 2024 08:18:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id 8984B3858287 for ; Fri, 26 Jan 2024 08:16:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8984B3858287 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8984B3858287 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706257000; cv=none; b=EAaiWDsJuGT/FTlgxRf/sYtBBSWVBw7iZCmeVc0blVbrXEkhGvAgDSwpgrKnWpC6hYn3hBBIlvzfptLFGoNZW6Cb615rqwvILHNq+km1bOTlQ9xE8hSenlPxNZhVp3IbNAuQ9pyr8QWzLc9FWRxDO3Wtf9XYgD1ZwB+CR8xsjQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706257000; c=relaxed/simple; bh=obPwND+/4r5wz3F2VahIWFZKUWE/XRcpMgQdM0vIQFo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=qXezW/THr9nDGne3/2OPOw8WQlc5CHp5mqZdaBwY46BifexMoZkY08niOw++7t+ig3bhf/PUSnXFZXcWV4aX2IQlMFEyzrBSCojnarJm8u0XKr9l9hJUy7xczlajkRdimRSOEQhXxrrB0ZjT+eiAMYS6alseCcxUx4cLp/TpeXs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a28fb463a28so10227466b.3 for ; Fri, 26 Jan 2024 00:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706256993; x=1706861793; darn=gcc.gnu.org; h=content-transfer-encoding:subject:from:to:content-language:cc :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=3s55RcyL8iW2L0B8qQcSAMEwdEBJTroNXaJY85/R46E=; b=SMw2u11wPy7UgVAh3nq6QuMAWm6nIMgPmPfzMP0XTYnkGFhsfaS6FGFKlhMpqwCDUd ucRkN2byoGShxQoTo1GLHu+95KtxYW8Ed5NFP+tqXFj0pmtc82kKnMgOj0PoXq/bd3iW sLCNQk6V8vieKsVoGbiMmt36CoQfLkKd0B8urogBbMatCxyegzU7giXKdV/95asInuZc NAns91+ZWwEAVWyZTCN1uaz0GkS1K3i5XXabJBdNENk4eZ/XTOKinUQUHhdw9s8rZV5I bEX/xaUTsKidpEhCZUzPloReOS7StpThuWKHHjdzkR61LxFZNkzR8jOCwHHb77VD/zqV vJjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706256993; x=1706861793; h=content-transfer-encoding:subject:from:to:content-language:cc :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=3s55RcyL8iW2L0B8qQcSAMEwdEBJTroNXaJY85/R46E=; b=vV2A8DqWBGTzjHki0WNVX5ti6UOnfuffT/VgImDQR5gc3N3G0rEs9WHCDTICQXsytr Xogkum3KTEX5msXWr2WriXvXe9/cquTrGkEYRTIjzXOWSzJDE6hfemPp9WU290nBtp5c TnPrsBjLFonJXmTHWSO9SHYN6Bx5n2faKWJMKXnQsNRaAtOo6BdYf2Mlhbz1NKGi3dWr yJhxkfs6/JO+XzQH78IURRToBt+ImrgH46zVFdCmdHcCu2QBaNV7TD3xtn03LBGTY6A2 Ebe1A4sDahkfLC+O5skLeWrgNi7in7hWiGMBJZepSM9ETnlf4uu8kGrZ/m+Qhf9Dchwt ZD+w== X-Gm-Message-State: AOJu0YwduHGtHtWh7b4f7HE0A5nC4w3L6gxpQxFxGSejvQugewHPgktQ 7vYC7hP+/52+yABLWcj7jpb4OFwmLO1Fn3iBshJAoy31rnFDBJcmMspg4lJ1 X-Received: by 2002:a17:906:eb53:b0:a2d:5392:6cc0 with SMTP id mc19-20020a170906eb5300b00a2d53926cc0mr428608ejb.60.1706256992683; Fri, 26 Jan 2024 00:16:32 -0800 (PST) Received: from [192.168.1.23] (ip-149-172-150-237.um42.pools.vodafone-ip.de. [149.172.150.237]) by smtp.gmail.com with ESMTPSA id jp15-20020a170906f74f00b00a2fde3a8097sm363995ejb.74.2024.01.26.00.16.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jan 2024 00:16:32 -0800 (PST) Message-ID: <77b98581-e3ac-4288-8ee0-f31416b95323@gmail.com> Date: Fri, 26 Jan 2024 09:16:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: rdapp.gcc@gmail.com Content-Language: en-US To: gcc-patches From: Robin Dapp Subject: [PATCH] genopinit: Split init_all_optabs [PR113575] X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789140224758053650 X-GMAIL-MSGID: 1789140224758053650 Hi, init_all_optabs initializes > 10000 patterns for riscv targets. This leads to pathological situations in dataflow analysis (which can occur with many adjacent stores). To alleviate this this patch makes genopinit split the init_all_optabs function into several init_optabs_xx functions that each initialize 1000 patterns. With this change insn-opinit.cc's compilation time is reduced from 4+ minutes to 1:30 and memory consumption decreases from 1.2G to 630M. Bootstrapped and regtested on x86 and aarch64 (where we do split) and on power10 (where we don't). Regtested on riscv. Regards Robin gcc/ChangeLog: PR other/113575 * genopinit.cc (main): Split init_all_optabs into functions of 1000 patterns each. --- gcc/genopinit.cc | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/gcc/genopinit.cc b/gcc/genopinit.cc index 88ccafa5b2c..d8682b2a9ad 100644 --- a/gcc/genopinit.cc +++ b/gcc/genopinit.cc @@ -367,11 +367,44 @@ main (int argc, const char **argv) fprintf (s_file, " { %#08x, CODE_FOR_%s },\n", p->sort_num, p->name); fprintf (s_file, "};\n\n"); - fprintf (s_file, "void\ninit_all_optabs (struct target_optabs *optabs)\n{\n"); - fprintf (s_file, " bool *ena = optabs->pat_enable;\n"); - for (i = 0; patterns.iterate (i, &p); ++i) - fprintf (s_file, " ena[%u] = HAVE_%s;\n", i, p->name); - fprintf (s_file, "}\n\n"); + /* Some targets like riscv have a large number of patterns. In order to + prevent pathological situations in dataflow analysis split the init + function into separate ones that initialize 1000 patterns each. */ + + const int patterns_per_function = 1000; + + if (patterns.length () > patterns_per_function) + { + unsigned num_init_functions + = patterns.length () / patterns_per_function + 1; + for (i = 0; i < num_init_functions; i++) + { + fprintf (s_file, "static void\ninit_optabs_%02d " + "(struct target_optabs *optabs)\n{\n", i); + fprintf (s_file, " bool *ena = optabs->pat_enable;\n"); + unsigned start = i * patterns_per_function; + unsigned end = MIN (patterns.length (), + (i + 1) * patterns_per_function); + for (j = start; j < end; ++j) + fprintf (s_file, " ena[%u] = HAVE_%s;\n", j, patterns[j].name); + fprintf (s_file, "}\n\n"); + } + + fprintf (s_file, "void\ninit_all_optabs " + "(struct target_optabs *optabs)\n{\n"); + for (i = 0; i < num_init_functions; ++i) + fprintf (s_file, " init_optabs_%02d (optabs);\n", i); + fprintf (s_file, "}\n\n"); + } + else + { + fprintf (s_file, "void\ninit_all_optabs " + "(struct target_optabs *optabs)\n{\n"); + fprintf (s_file, " bool *ena = optabs->pat_enable;\n"); + for (i = 0; patterns.iterate (i, &p); ++i) + fprintf (s_file, " ena[%u] = HAVE_%s;\n", i, p->name); + fprintf (s_file, "}\n\n"); + } fprintf (s_file, "/* Returns TRUE if the target supports any of the partial vector\n"