From: Julian Brown <julian@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Chung-Lin Tang <cltang@codesourcery.com>,
Jakub Jelinek <jakub@redhat.com>
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 [thread overview]
Message-ID: <ee286b9d6ac9c629ddbbe9f3c9975fc1e270d9dc.1628697740.git.julian@codesourcery.com> (raw)
In-Reply-To: <cover.1628697739.git.julian@codesourcery.com>
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 <julian@codesourcery.com>
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
next prev parent reply other threads:[~2021-08-11 16:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 16:58 [PATCH 0/8] OpenMP 5.0: Topological sort for OpenMP 5.0 base pointers Julian Brown
2021-08-11 16:58 ` [PATCH 1/8] Improve OpenMP target support for C++ [PR92120 v4b] Julian Brown
2021-08-11 16:58 ` [PATCH 2/8] OpenMP 5.0: Implement relaxation of implicit map vs. existing device mappings Julian Brown
2021-08-11 16:58 ` [PATCH 3/8] Remove array section base-pointer mapping semantics, and other front-end adjustments (mainline trunk) Julian Brown
2021-08-11 16:58 ` [PATCH 4/8] Rewrite GOMP_MAP_ATTACH_DETACH mappings unconditionally Julian Brown
2021-08-11 16:59 ` Julian Brown [this message]
2021-08-11 16:59 ` [PATCH 6/8] OpenACC/OpenMP: Refactor struct lowering in gimplify.c Julian Brown
2021-08-11 16:59 ` [PATCH 7/8] OpenACC: Rework indirect struct handling " Julian Brown
2021-08-11 16:59 ` [PATCH 8/8] OpenMP 5.0: [WIP, RFC] Clause ordering for OpenMP 5.0 (topological sorting by base pointer) Julian Brown
2021-10-04 15:59 ` Julian Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee286b9d6ac9c629ddbbe9f3c9975fc1e270d9dc.1628697740.git.julian@codesourcery.com \
--to=julian@codesourcery.com \
--cc=cltang@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).