From patchwork Thu Nov 25 14:07:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 48140 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 3D2583858004 for ; Thu, 25 Nov 2021 14:08:52 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 60707385841A for ; Thu, 25 Nov 2021 14:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 60707385841A 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: Y+kdwXDD5kcD44AG8Q2wLKcGBEv27hedmLkc8ugcL+SwiKdil5d0QHMZli/bqYYdpqOsHMd8ph O4WtNc7SUx0nLL/bIgJ85e/rbXWHEjucj+Ixqa//vGERWSpMK4VdyhQC86+jE/H4/W6yUNNlNu fncQT8J06oeuPMytKq0i/4XPgip0miE/ZgKnIWlngZzoz/73S+6ySeDDZ1P9ExRT7Qn0TKsBKx PoL4j7+R+A0LXh2UKKCep+xgzx9Fyn2m/BX36Fl4+bWkuTFJx0SNAuMQgQUZNh49F7zC+2ZYzp TSG0rTxy5GXSOh+c7RdSLdcc X-IronPort-AV: E=Sophos;i="5.87,263,1631606400"; d="scan'208";a="68920767" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 25 Nov 2021 06:07:39 -0800 IronPort-SDR: LMCGdGT2bZTYRoRVXth5Rv9cqmyst12pmv9vSlkgNAGmJs+mu70bv6SKPeGpeckLELYbnacisv U2i5I9mbzvR/eYVPgDSYRbSd94NqTmcBBBwjZtkyV1tVG7QgiONnXNfZjmB9E8MHTuqPSXnC8p 39RjgzOIAHsNbL8Lz6sBKG2JaLBUhGOTlM/ZCILBY68bGG4N60ib8S1NB05frIYpgOjaHGvAgr 8K5gGtHUDUh7lGeH8bgq9KEApoOGKVDYbJrXLM4ioJJROBL9Ze/2rHlgQ5/D7Ow5RDTNHDQRni YQU= From: Julian Brown To: Subject: [PATCH 02/16] OpenMP/OpenACC: Move array_ref/indirect_ref handling code out of extract_base_bit_offset Date: Thu, 25 Nov 2021 06:07:18 -0800 Message-ID: <20211125140720.108885-3-julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20211125140720.108885-1-julian@codesourcery.com> References: <20211125140720.108885-1-julian@codesourcery.com> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP 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: , Cc: Jakub Jelinek , Thomas Schwinge Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patch slightly cleans up the semantics of extract_base_bit_offset, in that the stripping of ARRAY_REFS/INDIRECT_REFS out of extract_base_bit_offset is moved back into the (two) call sites of the function. This is done in preparation for follow-on patches that extend the function. Previously posted for the og11 branch here (patch & reversion/rework): https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571712.html https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571884.html OK? Thanks, Julian 2021-06-03 Julian Brown gcc/ * gimplify.c (extract_base_bit_offset): Don't look through ARRAY_REFs or INDIRECT_REFs here. (build_struct_group): Reinstate previous behaviour for handling ARRAY_REFs/INDIRECT_REFs. --- gcc/gimplify.c | 59 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8d8735ae4c1..1baea68920b 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8675,31 +8675,7 @@ extract_base_bit_offset (tree base, tree *base_ref, poly_int64 *bitposp, poly_offset_int poffset; if (base_ref) - { - *base_ref = NULL_TREE; - - while (TREE_CODE (base) == ARRAY_REF) - base = TREE_OPERAND (base, 0); - - if (TREE_CODE (base) == INDIRECT_REF) - base = TREE_OPERAND (base, 0); - } - else - { - if (TREE_CODE (base) == ARRAY_REF) - { - while (TREE_CODE (base) == ARRAY_REF) - base = TREE_OPERAND (base, 0); - if (TREE_CODE (base) != COMPONENT_REF - || TREE_CODE (TREE_TYPE (base)) != ARRAY_TYPE) - return NULL_TREE; - } - else if (TREE_CODE (base) == INDIRECT_REF - && TREE_CODE (TREE_OPERAND (base, 0)) == COMPONENT_REF - && (TREE_CODE (TREE_TYPE (TREE_OPERAND (base, 0))) - == REFERENCE_TYPE)) - base = TREE_OPERAND (base, 0); - } + *base_ref = NULL_TREE; base = get_inner_reference (base, &bitsize, &bitpos, &offset, &mode, &unsignedp, &reversep, &volatilep); @@ -9673,12 +9649,17 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, poly_offset_int offset1; poly_int64 bitpos1; tree tree_offset1; - tree base_ref; + tree base_ref, ocd = OMP_CLAUSE_DECL (c); - tree base - = extract_base_bit_offset (OMP_CLAUSE_DECL (c), &base_ref, - &bitpos1, &offset1, - &tree_offset1); + while (TREE_CODE (ocd) == ARRAY_REF) + ocd = TREE_OPERAND (ocd, 0); + + if (TREE_CODE (ocd) == INDIRECT_REF) + ocd = TREE_OPERAND (ocd, 0); + + tree base = extract_base_bit_offset (ocd, &base_ref, + &bitpos1, &offset1, + &tree_offset1); bool do_map_struct = (base == decl && !tree_offset1); @@ -9871,6 +9852,24 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, poly_offset_int offsetn; poly_int64 bitposn; tree tree_offsetn; + + if (TREE_CODE (sc_decl) == ARRAY_REF) + { + while (TREE_CODE (sc_decl) == ARRAY_REF) + sc_decl = TREE_OPERAND (sc_decl, 0); + if (TREE_CODE (sc_decl) != COMPONENT_REF + || (TREE_CODE (TREE_TYPE (sc_decl)) + != ARRAY_TYPE)) + break; + } + else if (TREE_CODE (sc_decl) == INDIRECT_REF + && (TREE_CODE (TREE_OPERAND (sc_decl, 0)) + == COMPONENT_REF) + && (TREE_CODE (TREE_TYPE + (TREE_OPERAND (sc_decl, 0))) + == REFERENCE_TYPE)) + sc_decl = TREE_OPERAND (sc_decl, 0); + tree base = extract_base_bit_offset (sc_decl, NULL, &bitposn, &offsetn,