From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D49E7398642A for ; Wed, 11 Aug 2021 16:59:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D49E7398642A 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: 8kiT+kga/7mecxCdLcD5U+Bgz0WuPI5B9FS6A0dOk/U8vUyNIlY8UR5l+kPNg7ETL/bRTeFmOx yz8HAoCRSc+CI7t8cabsuyaFHFBkWB5wEUs9Nb/0B4FDnqUKbLxPayHx31cHylyVBTCxyELl0p CRiWLZY6kGEqtbHeLI5i7hBpdh6OlYJb72c/IcCX/+PRMY0Iczn1BW6EPhVeYWF+naZlRjQP+8 OzECenk5ITVv9sNy2WpvrzQgJYAsL7lpp5YTKC9oCaMwTM4dbFYWKLRyUqkXN6zW/Fb3WUyybL IMlzvjDFpFpIcUZICSHVL7uO X-IronPort-AV: E=Sophos;i="5.84,313,1620720000"; d="scan'208";a="64742392" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 11 Aug 2021 08:59:44 -0800 IronPort-SDR: NxpqipVr/1eEh5WjBi7pzn3NhKLooHo8PEd7/uty2kHCbSZxudZuXW+LUa3PYzOvYU/FV6lLVy IwQ2Eox9nMAds77CUNZBXZmI+joACGWGUa2qiDhCC/hB07rk+jD+s70mys4NrlnaNEYw2C5kiw KngfdGuF3SyfLZcQDZ6rCaHWf1UesAVeNBv39GPzu2T8vvDiX8eFZTXSbXorL8KodzYYNPgAZf LcLeTz4sImpFBcbQKbvPSQeNLz/KxoCb8mPkugKjLk+HZvRp/iT+ifGJaReCjRTAgb5AdUOBvp ZuI= From: Julian Brown To: CC: Chung-Lin Tang , Jakub Jelinek Subject: [PATCH 5/8] OpenMP/OpenACC: Move array_ref/indirect_ref handling code out of extract_base_bit_offset Date: Wed, 11 Aug 2021 09:59:32 -0700 Message-ID: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) 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: , X-List-Received-Date: Wed, 11 Aug 2021 16:59:55 -0000 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 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 141ef6b2b1e..974d25b2d05 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8490,31 +8490,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); @@ -9482,12 +9458,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); @@ -9679,6 +9660,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, -- 2.29.2