From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1410) id 9BE20395BC77; Wed, 2 Jun 2021 10:49:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BE20395BC77 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Julian Brown To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] [og11] Unify ARRAY_REF/INDIRECT_REF stripping code in extract_base_bit_offset X-Act-Checkin: gcc X-Git-Author: Julian Brown X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: 9aa75428f8b7d1e362ff5588c4bc35a50ae1b598 X-Git-Newrev: 309548a704fdfbf6b2786d0eac659d4a493af65f Message-Id: <20210602104954.9BE20395BC77@sourceware.org> Date: Wed, 2 Jun 2021 10:49:54 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 10:49:54 -0000 https://gcc.gnu.org/g:309548a704fdfbf6b2786d0eac659d4a493af65f commit 309548a704fdfbf6b2786d0eac659d4a493af65f Author: Julian Brown Date: Mon Apr 19 06:24:41 2021 -0700 [og11] Unify ARRAY_REF/INDIRECT_REF stripping code in extract_base_bit_offset For historical reasons, it seems that extract_base_bit_offset unnecessarily used two different ways to strip ARRAY_REF/INDIRECT_REF nodes from component accesses. I verified that the two ways of performing the operation gave the same results across the whole testsuite (and several additional benchmarks). The code was like this since an earlier "mechanical" refactoring by me, first posted here: https://gcc.gnu.org/pipermail/gcc-patches/2018-November/510503.html It was never clear to me if there was an important semantic difference between the two ways of stripping the base before calling get_inner_reference, but it appears that there is not, so one can go away. 2021-06-02 Julian Brown gcc/ * gimplify.c (extract_base_bit_offset): Unify ARRAY_REF/INDIRECT_REF stripping code in first call/subsequent call cases. Diff: --- gcc/gimplify.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index a38cd502aa5..255a2a648c1 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8527,31 +8527,21 @@ 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); + *base_ref = NULL_TREE; - if (TREE_CODE (base) == INDIRECT_REF) - base = TREE_OPERAND (base, 0); - } - else + if (TREE_CODE (base) == ARRAY_REF) { - 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)) + 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 = get_inner_reference (base, &bitsize, &bitpos, &offset, &mode, &unsignedp, &reversep, &volatilep);