From patchwork Fri Apr 3 10:43:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1266001 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@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Received: from sourceware.org (server2.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 48txPb4YsSz9sRY for ; Fri, 3 Apr 2020 21:44:01 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA288385DC09; Fri, 3 Apr 2020 10:43:57 +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 CEED5385DC09 for ; Fri, 3 Apr 2020 10:43:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CEED5385DC09 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: sKvbl17GywJ0v8iSHEQ863J2HV3J7SCHK7nM4a4cXEja+8tQlo0JXoO3GIObO7Hl9I2GJiGrhJ lDbPC5PGKdO9iZY3o6OcEGjQbtk0IQUzgp8EFaku2WhmCVFkKF4qb5d2iFum8o7msDlLdzThCR FQIFDOL9AaKf02qLROV9BDgrMYjESsmWlxTU0qkVM7z1fJX8hasAjMtzYxcMvr5qLepdglWPF/ DZ/OjYvkSyxsWS4aZMdrZat9XV4o4aTnNXRH2yqkiBRom9iTxaFnMq6VzgJNGWwr4txUWSpai+ 3KY= X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="diff'?scan'208";a="47413140" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa3.mentor.iphmx.com with ESMTP; 03 Apr 2020 02:43:53 -0800 IronPort-SDR: p2I/junxZ77FXoH0yd3MpVeuQhQxtOTjUlwiu+7y/18awmj9C7vPsKf2g8mVEZxyK4CcWGxNfd 2RP/mikhDzEOy3Sk4axntX6WA1AwwN9yzIVFB4wFovPDQv2CGdg+nhKfni+Q2nV66VMCvuHH79 pbcBjtd0TNFkLSB+n1n592HZgMbzW/JOaxQc/XNx9FOYQNxhoMDV7TKYoeEdky9bYtDm/p2evC 1tr+04eaYydt8ohchlw9UyN20xtKr+npyCUvr9MgXcf4CLbvaFsD6pJQmDpRqBAdcBdkXwe6hP jKc= Subject: =?utf-8?q?=5BPatch=5D_HSA=3A_omp-grid=2Ec_=E2=80=93_access_prope?= =?utf-8?q?r_clause_code_=28was=3A_Re=3A_=5BPatch=5D_omp-grid=2Ec_?= =?utf-8?q?=E2=80=93_add_cast_to_silence_different_enumeration_type?= =?utf-8?q?s_warning=29?= To: Jakub Jelinek , Martin Jambor References: <449b24ed-5395-1050-4c31-4a17807688cc@codesourcery.com> <20200403090800.GY2212@tucnak> From: Tobias Burnus Message-ID: <3b3992ae-4e3a-42ad-cdd7-7998bd8dbbe4@codesourcery.com> Date: Fri, 3 Apr 2020 12:43:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200403090800.GY2212@tucnak> Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-26.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: gcc-patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi Jakub, hi Martin, I think I misread some bits – after more code reading, I think it correctly sets '(NODE)->omp_clause.code' alias OMP_CLAUSE_CODE; Hence, using OMP_CLAUSE_CODE in the switch statement makes sense for the actual code usage (and, of course, also semantically). As I don't have HSA setup, I couldn't test it. This code is only called via omp-low.c's execute_lower_omp via: if (hsa_gen_requested_p ()) omp_grid_gridify_all_targets (&body); Hence, unsurprisingly, it did not make a difference when running the testsuite . OK? [The code was added (back then to omp-low.c) in commit 56b1c60e412fcf1245b4780871553cbdebb956a3 (r242761) with Martins' [plural ;-)] 'Merge from HSA branch to trunk'.] Tobias On 4/3/20 11:08 AM, Jakub Jelinek wrote: > On Fri, Apr 03, 2020 at 11:02:13AM +0200, Tobias Burnus wrote: >> Those are all for the same switch statement; >> >> gomp_for contains 'tree clauses' and this clauses's '->code' is used >> to handle store 'enum omp_clauses_code' values in in gimple.{h,c}. >> >> I think adding this cast (and only this one) makes sense and it >> also silences a (clang) compiler warning. > That looks wrong to me. If *pc are OMP_CLAUSES, then it should use > OMP_CLAUSE_CODE (c) instead of TREE_CODE (c). > If something creates a tree that has TREE_CODE OMP_CLAUSE_LINEAR, then > that looks very suspicios (TREE_CODE should be OMP_CLAUSE). > >> omp-grid.c – add cast to silence different enumeration types warning >> >> * omp-grid.c (grid_eliminate_combined_simd_part): Add cast >> to omp_clause_code to silence compiler warning. >> >> diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c >> index b98e45de6a0..878977da2f9 100644 >> --- a/gcc/omp-grid.c >> +++ b/gcc/omp-grid.c >> @@ -1058,21 +1058,21 @@ grid_eliminate_combined_simd_part (gomp_for *parloop) >> while (*tgt) >> tgt = &OMP_CLAUSE_CHAIN (*tgt); >> >> /* Copy over all clauses, except for linear clauses, which are turned into >> private clauses, and all other simd-specific clauses, which are >> ignored. */ >> tree *pc = gimple_omp_for_clauses_ptr (simd); >> while (*pc) >> { >> tree c = *pc; >> - switch (TREE_CODE (c)) >> + switch ((omp_clause_code) TREE_CODE (c)) >> { >> case OMP_CLAUSE_LINEAR: >> { >> tree priv = build_omp_clause (UNKNOWN_LOCATION, OMP_CLAUSE_PRIVATE); >> OMP_CLAUSE_DECL (priv) = OMP_CLAUSE_DECL (c); >> OMP_CLAUSE_CHAIN (priv) = NULL; >> *tgt = priv; >> tgt = &OMP_CLAUSE_CHAIN (priv); >> pc = &OMP_CLAUSE_CHAIN (c); >> break; > > Jakub > ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter HSA: omp-grid.c – access proper clause code * omp-grid.c (grid_eliminate_combined_simd_part): Use OMP_CLAUSE_CODE to access the omp clause code. diff --git a/gcc/omp-grid.c b/gcc/omp-grid.c index b98e45de6a0..ba635fd3ea2 100644 --- a/gcc/omp-grid.c +++ b/gcc/omp-grid.c @@ -1065,7 +1065,7 @@ grid_eliminate_combined_simd_part (gomp_for *parloop) while (*pc) { tree c = *pc; - switch (TREE_CODE (c)) + switch (OMP_CLAUSE_CODE (c)) { case OMP_CLAUSE_LINEAR: {