From patchwork Fri Nov 18 18:05:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 22412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp336348wrr; Fri, 18 Nov 2022 10:07:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DAHOYrqm/WcvZHDkk6VlqJSTNAMOnjEphYFyaYFU1as0Ps7nw+fR0X70fNiSAW0WDZ8HH X-Received: by 2002:a17:906:144c:b0:7ad:cda3:93c7 with SMTP id q12-20020a170906144c00b007adcda393c7mr7074940ejc.500.1668794846217; Fri, 18 Nov 2022 10:07:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668794846; cv=none; d=google.com; s=arc-20160816; b=ZGtHn6+jq6JWyxm3YmC39spGOFB2XZSElDF2wzdDkZUvOIw38419mIZ1IFvdXAii+Z CfK4ILRhbU0MKO5w29Dp5uXcVmf1+aAfjBPXdxsDkXUcDiVUBQY3UU8tcOLKt5sJw2Ia zbvljNqqf2NCvBZeLfQ3+KObVfzLHrGxZlKn3cNbN8nUoPJySrR6wt9hh8vq47I439A9 AwW2cFVBLrlc+rayG1G38ttGGU9D42ddDa64rljyx1YwU1J+Y/n5BD19jJ44BJnDyw/d BdJAOBz3xwDGktUkjOeUJof4YbV63mlQiXAteoKgjjLD+bpl+T2zyKPYk8OutWd8IQpl MfGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=+BfqaB+Bm4TWjlY4OKGitdVlZ7yYQgjUzcyINOG0V1w=; b=vFP4Rz4wKySzh/N25v4jxXlNgJy20F895snGjo9MXyYOMspi8QOcZ9sc9mZRSLIfB6 3sk5pjcdLqe/5DSN+SB6YSuBGv2LEq4By86laF1D4E5y3BMUHNE+igI90I0bxDzdlWQ0 6risnbdvkhcWVvFD2ugdV4fJxTwFRsc8JCSM1kITrZOuHd+gk3BOUmU2pH//JmrVW1dv +m83V1cFcgm28iICClocCrfTPGcabOgpgfFVQrKJrmg2G1g5fUi4hSA7jWIyX2gEOLNg jg+NQBlAX5Eid3ZsvmbCXdlCgwwVySm52E2ycJDzVpYLJ9/QLQ8Pt2BmFndCmxed1a9M H1kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A0wRrfYm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qa35-20020a17090786a300b007771bc8dbb4si4063207ejc.781.2022.11.18.10.07.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 10:07:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@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=@gcc.gnu.org header.s=default header.b=A0wRrfYm; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A90C3853D6E for ; Fri, 18 Nov 2022 18:07:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A90C3853D6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668794845; bh=+BfqaB+Bm4TWjlY4OKGitdVlZ7yYQgjUzcyINOG0V1w=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=A0wRrfYm1PrUfoAqUQhjDOXPsdIYolc2WsjKIHqCUa/d/VH5/EzCp2ZmahaRvPa0y UaQD+MvLE+3WzbuNk2+sOzTYApqPTMZTcCb6+PIPDlq4SguEbCWyxKRerUiYyLP/YT 58DDW6raXaZ6EzA/hszM4M5awJ/yTFSmDmy87qcA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by sourceware.org (Postfix) with ESMTPS id 4E794385841C for ; Fri, 18 Nov 2022 18:05:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4E794385841C Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AIFUptq003440 for ; Fri, 18 Nov 2022 10:05:39 -0800 Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3kx0utb4w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 18 Nov 2022 10:05:39 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 18 Nov 2022 10:05:37 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 18 Nov 2022 10:05:37 -0800 Received: from linux.wrightpinski.org.com (unknown [10.69.242.198]) by maili.marvell.com (Postfix) with ESMTP id BEE883F7054; Fri, 18 Nov 2022 10:05:36 -0800 (PST) To: CC: Andrew Pinski Subject: [PATCH] constexprify some tree variables Date: Fri, 18 Nov 2022 10:05:31 -0800 Message-ID: <1668794731-9349-1-git-send-email-apinski@marvell.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Proofpoint-GUID: 4__hOgIcT0mGouf5LSiXh3gUeda3PuA0 X-Proofpoint-ORIG-GUID: 4__hOgIcT0mGouf5LSiXh3gUeda3PuA0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-18_06,2022-11-18_01,2022-06-22_01 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: apinski--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: apinski@marvell.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749858224560133280?= X-GMAIL-MSGID: =?utf-8?q?1749858224560133280?= From: Andrew Pinski Since we use C++11 by default now, we can use constexpr for some const decls in tree-core.h. This patch does that and it allows for better optimizations of GCC code with checking enabled and without LTO. For an example generic-match.cc compiling is speed up due to the less number of basic blocks and less debugging info produced. I did not check the speed of compiling the same source but rather the speed of compiling the old vs new sources here (but with the same compiler base). The small slow down in the parsing of the arrays in each TU is migrated by a speed up in how much code/debugging info is produced in the end. Note I looked at generic-match.cc since it is one of the compiling sources which causes parallel building to stall and I wanted to speed it up. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Or should this wait until GCC 13 branches off? gcc/ChangeLog: PR middle-end/14840 * tree-core.h (tree_code_type): Constexprify by including all-tree.def. (tree_code_length): Likewise. * tree.cc (tree_code_type): Remove. (tree_code_length): Remove. --- gcc/tree-core.h | 21 +++++++++++++++++++-- gcc/tree.cc | 24 ------------------------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/gcc/tree-core.h b/gcc/tree-core.h index af75522504f..e146b133dbd 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -2284,15 +2284,32 @@ struct floatn_type_info { /* Matrix describing the structures contained in a given tree code. */ extern bool tree_contains_struct[MAX_TREE_CODES][64]; +#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, +#define END_OF_BASE_TREE_CODES tcc_exceptional, + + /* Class of tree given its code. */ -extern const enum tree_code_class tree_code_type[]; +constexpr enum tree_code_class tree_code_type[] = { +#include "all-tree.def" +}; + +#undef DEFTREECODE +#undef END_OF_BASE_TREE_CODES /* Each tree code class has an associated string representation. These must correspond to the tree_code_class entries. */ extern const char *const tree_code_class_strings[]; /* Number of argument-words in each kind of tree-node. */ -extern const unsigned char tree_code_length[]; + +#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, +#define END_OF_BASE_TREE_CODES 0, +constexpr unsigned char tree_code_length[] = { +#include "all-tree.def" +}; + +#undef DEFTREECODE +#undef END_OF_BASE_TREE_CODES /* Vector of all alias pairs for global symbols. */ extern GTY(()) vec *alias_pairs; diff --git a/gcc/tree.cc b/gcc/tree.cc index 574bd2e65d9..254b2373dcf 100644 --- a/gcc/tree.cc +++ b/gcc/tree.cc @@ -74,31 +74,7 @@ along with GCC; see the file COPYING3. If not see #include "asan.h" #include "ubsan.h" -/* Tree code classes. */ -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, -#define END_OF_BASE_TREE_CODES tcc_exceptional, - -const enum tree_code_class tree_code_type[] = { -#include "all-tree.def" -}; - -#undef DEFTREECODE -#undef END_OF_BASE_TREE_CODES - -/* Table indexed by tree code giving number of expression - operands beyond the fixed part of the node structure. - Not used for types or decls. */ - -#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, -#define END_OF_BASE_TREE_CODES 0, - -const unsigned char tree_code_length[] = { -#include "all-tree.def" -}; - -#undef DEFTREECODE -#undef END_OF_BASE_TREE_CODES /* Names of tree components. Used for printing out the tree and error messages. */