From patchwork Tue Aug 31 18:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 1522744 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gzbrc2KlTz9sSs for ; Wed, 1 Sep 2021 04:51:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D1FD23858424 for ; Tue, 31 Aug 2021 18:51:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 873AB3858C27 for ; Tue, 31 Aug 2021 18:51:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 873AB3858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: dKFaGIBrzoxAcB4qbqKLAHZHyKwSZW69pDQUT51VyDVv0aNS+njBxs5UUZEsr43BvtQSa8Nrdh LboLnqxta42OyEoIJHD2i5nYWNd0OzVtHrHyZhxek/kuVIKd8X4SEzhoxloGl+kT/dxJgf8ITm yVXiOVaV1iQfFMgQu0cfVeE8DVxf/8klgvs+R0B832/SUYrmnMJ7e0jL4FeB/QcKvNh6X3bqv5 A3tjLjZWK4kU75uhKWh4uWyVpBg8BDEMpTLqmSqjM/nDxKSLJqg1JINthsoK71N6HTZQE3MxER Bqc= X-IronPort-AV: E=Sophos;i="5.84,367,1620720000"; d="scan'208,223";a="65326857" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 31 Aug 2021 10:51:24 -0800 IronPort-SDR: vKuKZHLEPSYp7HJKp+K82HiK7IaEP9NKDimpuLl6FG4tSt57ccOBCPGB/9Mipi2nWbHqwsGp8p R5CwUw1iYHFuuWOxXmXYPfy3i0MAlkWYS7z1NZyMwfQ16GOgDoimbemNsrvWtP8moxRKEtZVzX fmvrBpB9qXQPut04joz/3RxrVycmzx3wjCns91CWyNJ2yNUcG5fjzadS34pCKlIIfCQfCnglb+ z9GBKfc4MWqYmN5BlOJEdXUgRRf2Jsg9UJQi5X0/pqXnqq0L+Uj/NOdDb9GSPcBRDafbfpZZGL EUY= From: Thomas Schwinge To: , Jakub Jelinek Subject: Simplify 'gcc/tree.c:walk_tree_1' handling of 'OMP_CLAUSE' (was: Fix PR 25886. Convert OMP_CLAUSE_* into sub-codes.) In-Reply-To: <43D7B83A.3060802@redhat.com> References: <43D7B83A.3060802@redhat.com> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Tue, 31 Aug 2021 20:51:16 +0200 Message-ID: <87tuj55ty3.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, UPPERCASE_50_75 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2006-01-25T12:41:14-0500, Diego Novillo wrote: > This patch replaces all the OMP_CLAUSE_* tree codes with a single > OMP_CLAUSE tree with sub-codes. So, originally all OMP clauses were represented by their own tree codes, which all had to be enumerated/handled individually. But, with all these having been unified into 'OMP_CLAUSE'... > --- tree.c (revision 110178) > +++ tree.c (working copy) ..., and given this: > +/* Number of operands for each OpenMP clause. */ > +unsigned char omp_clause_num_ops[] = > +{ > + 0, /* OMP_CLAUSE_ERROR */ > + 1, /* OMP_CLAUSE_PRIVATE */ > + 1, /* OMP_CLAUSE_SHARED */ > + 1, /* OMP_CLAUSE_FIRSTPRIVATE */ > + 1, /* OMP_CLAUSE_LASTPRIVATE */ > + 4, /* OMP_CLAUSE_REDUCTION */ > + 1, /* OMP_CLAUSE_COPYIN */ > + 1, /* OMP_CLAUSE_COPYPRIVATE */ > + 1, /* OMP_CLAUSE_IF */ > + 1, /* OMP_CLAUSE_NUM_THREADS */ > + 1, /* OMP_CLAUSE_SCHEDULE */ > + 0, /* OMP_CLAUSE_NOWAIT */ > + 0, /* OMP_CLAUSE_ORDERED */ > + 0 /* OMP_CLAUSE_DEFAULT */ > +}; ..., we may simplify this: > @@ -7303,30 +7433,38 @@ walk_tree (tree *tp, walk_tree_fn func, > } > break; > > - case OMP_CLAUSE_PRIVATE: > -[...] > - case OMP_CLAUSE_SCHEDULE: > - WALK_SUBTREE (TREE_OPERAND (*tp, 0)); > - /* FALLTHRU */ > + case OMP_CLAUSE: > + switch (OMP_CLAUSE_CODE (*tp)) > + { > + case OMP_CLAUSE_PRIVATE: > +[...] > + case OMP_CLAUSE_SCHEDULE: > + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0)); > + /* FALLTHRU */ > > - case OMP_CLAUSE_NOWAIT: > - case OMP_CLAUSE_ORDERED: > - case OMP_CLAUSE_DEFAULT: > - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); > + case OMP_CLAUSE_NOWAIT: > + case OMP_CLAUSE_ORDERED: > + case OMP_CLAUSE_DEFAULT: > + WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); > > - case OMP_CLAUSE_REDUCTION: > - { > - int i; > - for (i = 0; i < 4; i++) > - WALK_SUBTREE (TREE_OPERAND (*tp, i)); > - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); > - } > + case OMP_CLAUSE_REDUCTION: > + { > + int i; > + for (i = 0; i < 4; i++) > + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); > + WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); > + } > + > + default: > + gcc_unreachable (); > + } > + break; ... considerably? OK to push to master branch the attached "Simplify 'gcc/tree.c:walk_tree_1' handling of 'OMP_CLAUSE'"? Grüße Thomas ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 4a22fd8b55cd1fe6fad1940127d09b30f47c90b2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Fri, 27 Aug 2021 07:49:55 +0200 Subject: [PATCH] Simplify 'gcc/tree.c:walk_tree_1' handling of 'OMP_CLAUSE' No behavioral change, other than that for a few clauses, operands are now walked in a different order, and 'OMP_CLAUSE_ERROR' now no longer runs into 'default: gcc_unreachable ();' here (but instead will at some later stage). Follow-up for r110243 (commit aaf46ef9792bbc562175b606bd1c3f225ea56924) "Fix PR 25886. Convert OMP_CLAUSE_* into sub-codes". gcc/ * tree.c (walk_tree_1) : Simplify. --- gcc/tree.c | 134 ++++------------------------------------------------- 1 file changed, 8 insertions(+), 126 deletions(-) diff --git a/gcc/tree.c b/gcc/tree.c index 4c7e03b0f25..99571f8f9b8 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -275,7 +275,7 @@ struct int_n_trees_t int_n_trees [NUM_INT_N_ENTS]; bool tree_contains_struct[MAX_TREE_CODES][64]; -/* Number of operands for each OpenMP clause. */ +/* Number of operands for each OMP clause. */ unsigned const char omp_clause_num_ops[] = { 0, /* OMP_CLAUSE_ERROR */ @@ -10289,7 +10289,7 @@ build_empty_stmt (location_t loc) } -/* Build an OpenMP clause with code CODE. LOC is the location of the +/* Build an OMP clause with code CODE. LOC is the location of the clause. */ tree @@ -11091,130 +11091,12 @@ walk_tree_1 (tree *tp, walk_tree_fn func, void *data, break; case OMP_CLAUSE: - switch (OMP_CLAUSE_CODE (*tp)) - { - case OMP_CLAUSE_GANG: - WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 1)); - /* FALLTHRU */ - - case OMP_CLAUSE_AFFINITY: - case OMP_CLAUSE_ASYNC: - case OMP_CLAUSE_WAIT: - case OMP_CLAUSE_WORKER: - case OMP_CLAUSE_VECTOR: - case OMP_CLAUSE_NUM_GANGS: - case OMP_CLAUSE_NUM_WORKERS: - case OMP_CLAUSE_VECTOR_LENGTH: - case OMP_CLAUSE_PRIVATE: - case OMP_CLAUSE_SHARED: - case OMP_CLAUSE_FIRSTPRIVATE: - case OMP_CLAUSE_COPYIN: - case OMP_CLAUSE_COPYPRIVATE: - case OMP_CLAUSE_FINAL: - case OMP_CLAUSE_IF: - case OMP_CLAUSE_NUM_THREADS: - case OMP_CLAUSE_SCHEDULE: - case OMP_CLAUSE_UNIFORM: - case OMP_CLAUSE_DEPEND: - case OMP_CLAUSE_NONTEMPORAL: - case OMP_CLAUSE_NUM_TEAMS: - case OMP_CLAUSE_THREAD_LIMIT: - case OMP_CLAUSE_DEVICE: - case OMP_CLAUSE_DIST_SCHEDULE: - case OMP_CLAUSE_SAFELEN: - case OMP_CLAUSE_SIMDLEN: - case OMP_CLAUSE_ORDERED: - case OMP_CLAUSE_PRIORITY: - case OMP_CLAUSE_GRAINSIZE: - case OMP_CLAUSE_NUM_TASKS: - case OMP_CLAUSE_HINT: - case OMP_CLAUSE_FILTER: - case OMP_CLAUSE_TO_DECLARE: - case OMP_CLAUSE_LINK: - case OMP_CLAUSE_DETACH: - case OMP_CLAUSE_USE_DEVICE_PTR: - case OMP_CLAUSE_USE_DEVICE_ADDR: - case OMP_CLAUSE_IS_DEVICE_PTR: - case OMP_CLAUSE_INCLUSIVE: - case OMP_CLAUSE_EXCLUSIVE: - case OMP_CLAUSE__LOOPTEMP_: - case OMP_CLAUSE__REDUCTEMP_: - case OMP_CLAUSE__CONDTEMP_: - case OMP_CLAUSE__SCANTEMP_: - case OMP_CLAUSE__SIMDUID_: - WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 0)); - /* FALLTHRU */ - - case OMP_CLAUSE_INDEPENDENT: - case OMP_CLAUSE_NOWAIT: - case OMP_CLAUSE_DEFAULT: - case OMP_CLAUSE_UNTIED: - case OMP_CLAUSE_MERGEABLE: - case OMP_CLAUSE_PROC_BIND: - case OMP_CLAUSE_DEVICE_TYPE: - case OMP_CLAUSE_INBRANCH: - case OMP_CLAUSE_NOTINBRANCH: - case OMP_CLAUSE_FOR: - case OMP_CLAUSE_PARALLEL: - case OMP_CLAUSE_SECTIONS: - case OMP_CLAUSE_TASKGROUP: - case OMP_CLAUSE_NOGROUP: - case OMP_CLAUSE_THREADS: - case OMP_CLAUSE_SIMD: - case OMP_CLAUSE_DEFAULTMAP: - case OMP_CLAUSE_ORDER: - case OMP_CLAUSE_BIND: - case OMP_CLAUSE_AUTO: - case OMP_CLAUSE_SEQ: - case OMP_CLAUSE__SIMT_: - case OMP_CLAUSE_IF_PRESENT: - case OMP_CLAUSE_FINALIZE: - case OMP_CLAUSE_NOHOST: - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - - case OMP_CLAUSE_LASTPRIVATE: - WALK_SUBTREE (OMP_CLAUSE_DECL (*tp)); - WALK_SUBTREE (OMP_CLAUSE_LASTPRIVATE_STMT (*tp)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - - case OMP_CLAUSE_COLLAPSE: - case OMP_CLAUSE_TILE: - { - int i; - for (i = 0; i < 3; i++) - WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - } - - case OMP_CLAUSE_LINEAR: - WALK_SUBTREE (OMP_CLAUSE_DECL (*tp)); - WALK_SUBTREE (OMP_CLAUSE_LINEAR_STEP (*tp)); - WALK_SUBTREE (OMP_CLAUSE_LINEAR_STMT (*tp)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - - case OMP_CLAUSE_ALIGNED: - case OMP_CLAUSE_ALLOCATE: - case OMP_CLAUSE_FROM: - case OMP_CLAUSE_TO: - case OMP_CLAUSE_MAP: - case OMP_CLAUSE__CACHE_: - WALK_SUBTREE (OMP_CLAUSE_DECL (*tp)); - WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, 1)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - - case OMP_CLAUSE_REDUCTION: - case OMP_CLAUSE_TASK_REDUCTION: - case OMP_CLAUSE_IN_REDUCTION: - { - int i; - for (i = 0; i < 5; i++) - WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); - WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); - } - - default: - gcc_unreachable (); - } + { + int len = omp_clause_num_ops[OMP_CLAUSE_CODE (*tp)]; + for (int i = 0; i < len; i++) + WALK_SUBTREE (OMP_CLAUSE_OPERAND (*tp, i)); + WALK_SUBTREE_TAIL (OMP_CLAUSE_CHAIN (*tp)); + } break; case TARGET_EXPR: -- 2.30.2