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: 60853 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6AA42385220F for ; Fri, 18 Nov 2022 18:07:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AA42385220F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668794829; 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=Nh8r4XCNNvyl7GlyMIjeHdjsDN1mqDIHPgGxcIjrUAzhrjQRdrT3nK2YM70eUWYt6 uPWodzL6+NJhiFapzq1hSx6qoDZGV51XH0+0Dgvekn/QHjV1s3HPMVszE6qc1l0dSA izXFirf3rhcFGfESpyL8tOnRK+mMmuC1wu9puoBo= 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. */