From: Tobias Burnus <burnus@net-b.de>
To: Julian Brown <julian@codesourcery.com>,
Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org, jakub@redhat.com
Subject: Re: [PATCH 1/8] OpenMP: lvalue parsing for map/to/from clauses (C++)
Date: Sun, 7 Jan 2024 16:04:37 +0100 [thread overview]
Message-ID: <0f3ec635-a817-4fa8-b307-6f977cda8642@net-b.de> (raw)
In-Reply-To: <20240105122326.1f89c4d6@squid.athome>
Am 05.01.24 um 13:23 schrieb Julian Brown:
> On Wed, 20 Dec 2023 15:31:15 +0100
> Tobias Burnus<tobias@codesourcery.com> wrote:
> Here's a rebased/retested version which fixes those bits (I haven't
> adjusted the libgomp.texi bit you noted yet, though).
>
> How does this look now?
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -13499,7 +13499,11 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
> if (TREE_CODE (dtype) == REFERENCE_TYPE)
> dtype = TREE_TYPE (dtype);
> /* FIRSTPRIVATE_POINTER doesn't work well if we have a
> - multiply-indirected pointer. */
> + multiply-indirected pointer. If we have a reference to a pointer to
> + a pointer, it's possible that this should really be
> + GOMP_MAP_FIRSTPRIVATE_REFERENCE -- but that also doesn't work at the
> + moment, so stick with this. (See testcase
> + baseptrs-4.C:ref2ptrptr_offset_decl_member_slice). */
Looks as we should have a tracking PR about this; can you file one?
* * *
> + if (processing_template_decl)
> + {
> + if (type_dependent_expression_p (array_expr)
> + || type_dependent_expression_p (index)
> + || type_dependent_expression_p (length))
> + return build_min_nt_loc (loc, OMP_ARRAY_SECTION, array_expr, index,
> + length);
> + }
I personally find it more readable if combined in a single 'if' condition.
> + /* Turn *foo into foo[0:1]. */
> + decl = TREE_OPERAND (decl, 0);
> + STRIP_NOPS (decl);
> +
> + /* If we have "*foo" and
> + - it's an indirection of a reference, "unconvert" it, i.e.
> + strip the indirection (to just "foo").
> + - it's an indirection of a pointer, turn it into
> + "foo[0:1]". */
> + if (!ref_p)
> + decl = grok_omp_array_section (loc, decl, integer_zero_node,
> + integer_one_node);
I would remove the first comment and remove the two succeeding lines
below the second comment.
> + /* This code rewrites a parsed expression containing various tree
> + codes used to represent array accesses into a more uniform nest of
> + OMP_ARRAY_SECTION nodes before it is processed by
> + semantics.cc:handle_omp_array_sections_1. It might be more
> + efficient to move this logic to that function instead, analysing
> + the parsed expression directly rather than this preprocessed
> + form. */
Or to do this transformation in handle_omp_array_sections to get still a
unified result in the middle end. I see advantages of all three
solutions. (Doing this in parse.cc (as currently done) feels a bit odd,
though.)
* * *
> build_omp_array_section (location_t loc, tree array_expr, tree index,
> + tree length)
> +{
> + tree idxtype;
> +
> + /* If we know the integer bounds, create an index type with exact
> + low/high (or zero/length) bounds. Otherwise, create an incomplete
> + array type. (This mostly only affects diagnostics.) */
> + if (index != NULL_TREE
> + && length != NULL_TREE
> + && TREE_CODE (index) == INTEGER_CST
> + && TREE_CODE (length) == INTEGER_CST)
> + {
> + tree low = fold_convert (sizetype, index);
> + tree high = fold_convert (sizetype, length);
> + high = size_binop (PLUS_EXPR, low, high);
> + high = size_binop (MINUS_EXPR, high, size_one_node);
> + idxtype = build_range_type (sizetype, low, high);
> + }
> + else if ((index == NULL_TREE || integer_zerop (index))
> + && length != NULL_TREE
> + && TREE_CODE (length) == INTEGER_CST)
> + idxtype = build_index_type (length);
> + else
> + idxtype = NULL_TREE;
> +
> + tree type = TREE_TYPE (array_expr);
> + gcc_assert (type);
> + type = non_reference (type);
> +
> + tree sectype, eltype = TREE_TYPE (type);
> +
> + /* It's not an array or pointer type. Just reuse the type of the
> + original expression as the type of the array section (an error will be
> + raised anyway, later). */
> + if (eltype == NULL_TREE)
> + sectype = TREE_TYPE (array_expr);
> + else
> + sectype = build_array_type (eltype, idxtype);
> +
> + return build3_loc (loc, OMP_ARRAY_SECTION, sectype, array_expr, index,
> + length);
> +}
I wonder whether it would be more readable if one moves all the
'idxtype' handling into the last 'else' branch.
* * *
LGTM - please file the PR and consider the readability items above.
Thanks,
Tobias
next prev parent reply other threads:[~2024-01-07 15:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-05 19:28 [PATCH 0/8] OpenMP: lvalue parsing and "declare mapper" support Julian Brown
2023-09-05 19:28 ` [PATCH 1/8] OpenMP: lvalue parsing for map/to/from clauses (C++) Julian Brown
2023-12-20 14:31 ` Tobias Burnus
2024-01-05 12:23 ` Julian Brown
2024-01-07 15:04 ` Tobias Burnus [this message]
2024-01-09 23:02 ` Thomas Schwinge
2024-01-10 9:14 ` Jakub Jelinek
2024-01-10 13:17 ` Julian Brown
2023-09-05 19:28 ` [PATCH 2/8] OpenMP: lvalue parsing for map/to/from clauses (C) Julian Brown
2024-01-10 21:31 ` Tobias Burnus
2023-09-05 19:28 ` [PATCH 3/8] OpenMP: C++ "declare mapper" support Julian Brown
2023-09-05 19:28 ` [PATCH 4/8] OpenMP: Support OpenMP 5.0 "declare mapper" directives for C Julian Brown
2023-09-05 19:28 ` [PATCH 5/8] OpenMP, Fortran: Pass list number to gfc_free_omp_namelist Julian Brown
2023-09-05 19:28 ` [PATCH 6/8] OpenMP, Fortran: Per-directive control for gfc_trans_omp_clauses Julian Brown
2023-09-05 19:28 ` [PATCH 7/8] OpenMP, Fortran: Split out OMP clause checking Julian Brown
2023-09-05 19:28 ` [PATCH 8/8] OpenMP: Fortran "!$omp declare mapper" support Julian Brown
2023-09-14 15:13 ` Bernhard Reutner-Fischer
2023-09-18 10:19 ` Julian Brown
2023-09-21 22:52 ` Bernhard Reutner-Fischer
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=0f3ec635-a817-4fa8-b307-6f977cda8642@net-b.de \
--to=burnus@net-b.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=julian@codesourcery.com \
--cc=tobias@codesourcery.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).