From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id ACEE53858D33 for ; Fri, 26 Jan 2024 12:22:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ACEE53858D33 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 ACEE53858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::12a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706271732; cv=none; b=EnJQc5D4IAsVVDb4+4lNDQ302XDGDEgCeaimCJiVvOgvlbgQ03Mff8FGwlg0O9zQl7l5e3u07F3RDnYx6GiIgYyHnYUMnvO80MmA08sCPw3k/7wqfQ8Qx2vk4cN73IisKT8N3PxCaxL/d2vFYcna3vyfD92AWrfUIJ2wiNLG+rM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706271732; c=relaxed/simple; bh=jj/Zbmy3NPCx0Up/++leGckvEY9savtuKs+dE19o5VM=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=dGi4Q4M+tF0gU8HSi4WSFYn/TG9imyNONGeL9tNAnlYWTalXgBIeKUFRnQ73rx6Q3ooHEPejH7dodixmBIOG8XkIO40VwqEoMCJBbJc+xrkEvBCuptbTBJO3oEhjrTRs9E8bb6L8aFo0TxiQsKYJWZ1hukGK/QZHlLQvVfjWXmA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5100cb64e7dso550001e87.0 for ; Fri, 26 Jan 2024 04:22:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706271727; x=1706876527; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1nAbmJy4bqVhe4ecjdO0gcSx9tYm+LljmMd0ZrSyXNs=; b=i6AvppAtDJYDeWoVkhfYOelySM/VCZioL+TCejH/MPlHpW9+pQv4XvaIlTKicouBwf yKQVGXcQxpLecfsrbfb6/uXP++dquB7e6vp74liRly25ZErnGbkRDafaa/Py0ZFMPccB qh147zSDGLyDEI3163EW8R5Rl+Gc/+hWCT8VJ9dsHKirh3ne1VMVScPuZjNaprlDUE7F h2nH91dazYdbgJNn8kb8qdh7OKhPHvt6OvjHor9dOhGvGP8krnxDkymbw/vQZPQmf1u5 g+09MvWN58Vno0yqWh4c1hwU+MFwRKoZoAL8FURCqVHsXIU9jibS3g+d3ZZhsmQV4C8T bTCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706271727; x=1706876527; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1nAbmJy4bqVhe4ecjdO0gcSx9tYm+LljmMd0ZrSyXNs=; b=iYXdRm0ZPZfzdk5RCFQavr1wUpBi7KOFTPQCTfY26JeYm2Z4cdHn+CPzoAv4lb4rdo WO/AC2soP68f8nPl4QhyzFl/nFDU0ivF1ymFfPOc/rWfxO11JO1XvxUx0gP9X80VRuF+ oRi3KiF8lIVgLNVMm05+9Oo1sZ+7IEscIQBi5phwNavQjhiKMkvnAMaM5Y6FDgND/SgM ml9vvEHhWqipn7NCNf3mxfzVtqJxZo+zMbLUpb8/YJKJGWXLh3EgRNtXxzDzLj5LF3rb uEyhb1UaRvvJNrORNCXEQR54uhn8wAo/lNZyZcL6F2fhPmk56eILd/+NtwIfCPTRptDO 9Y4A== X-Gm-Message-State: AOJu0YyBi4pr1XEV9sPfvCV6GNRucyVQ+w7PT31YRyHyo1MxhQh3VVuQ 7xveW7yPBwU9r1ahOq2t3MebDtyyTWPpxl697ZYdOnYLZosE9bzeTvNLmDBmSRZ7a4vuDFdrKqf ZnDoe9NWGS43lLJOglxLPGrr0ERI= X-Google-Smtp-Source: AGHT+IH754Dg4tQZYCTGNlD5u4j9YmuilVSVE5L2GPv0iW5h0eO1F8yFbPjmNgL5pC05WXefiscXB530EJ1g4v57GKo= X-Received: by 2002:ac2:55a1:0:b0:50e:b3b0:d5be with SMTP id y1-20020ac255a1000000b0050eb3b0d5bemr292580lfg.8.1706271726461; Fri, 26 Jan 2024 04:22:06 -0800 (PST) MIME-Version: 1.0 References: <77b98581-e3ac-4288-8ee0-f31416b95323@gmail.com> In-Reply-To: <77b98581-e3ac-4288-8ee0-f31416b95323@gmail.com> From: Richard Biener Date: Fri, 26 Jan 2024 13:21:55 +0100 Message-ID: Subject: Re: [PATCH] genopinit: Split init_all_optabs [PR113575] To: Robin Dapp Cc: gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.5 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 List-Id: On Fri, Jan 26, 2024 at 9:17=E2=80=AFAM Robin Dapp wr= ote: > > 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. OK. Thanks, Richard. > 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 =3D optabs->pat_enable;\n"); > - for (i =3D 0; patterns.iterate (i, &p); ++i) > - fprintf (s_file, " ena[%u] =3D 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 =3D 1000; > + > + if (patterns.length () > patterns_per_function) > + { > + unsigned num_init_functions > + =3D patterns.length () / patterns_per_function + 1; > + for (i =3D 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 =3D optabs->pat_enable;\n"); > + unsigned start =3D i * patterns_per_function; > + unsigned end =3D MIN (patterns.length (), > + (i + 1) * patterns_per_function); > + for (j =3D start; j < end; ++j) > + fprintf (s_file, " ena[%u] =3D HAVE_%s;\n", j, patterns[j].n= ame); > + fprintf (s_file, "}\n\n"); > + } > + > + fprintf (s_file, "void\ninit_all_optabs " > + "(struct target_optabs *optabs)\n{\n"); > + for (i =3D 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 =3D optabs->pat_enable;\n"); > + for (i =3D 0; patterns.iterate (i, &p); ++i) > + fprintf (s_file, " ena[%u] =3D HAVE_%s;\n", i, p->name); > + fprintf (s_file, "}\n\n"); > + } > > fprintf (s_file, > "/* Returns TRUE if the target supports any of the partial vec= tor\n" > -- > 2.43.0