From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] OpenMP: Fix use_device_{addr,ptr} with in-data-sharing arg
Date: Wed, 4 May 2022 14:03:37 +0200 [thread overview]
Message-ID: <YnJrmRQpbmmVhJ/1@tucnak> (raw)
In-Reply-To: <b4b56c8e-4c35-132c-1a75-0fe18ee07d71@codesourcery.com>
On Wed, Apr 20, 2022 at 03:19:38PM +0200, Tobias Burnus wrote:
> For array-descriptor vars, the descriptor is assigned to a temporary. However,
> this failed when the clause's argument was in turn in a data-sharing clause
> as the outer context's VALUE_EXPR wasn't used.
>
> gcc/ChangeLog:
>
> * omp-low.cc (lower_omp_target): Fix use_device_{addr,ptr} with list
> item that is in an outer data-sharing clause.
>
> libgomp/ChangeLog:
>
> * testsuite/libgomp.fortran/use_device_addr-5.f90: New test.
>
> gcc/omp-low.cc | 22 ++--
> .../libgomp.fortran/use_device_addr-5.f90 | 143 +++++++++++++++++++++
> 2 files changed, 156 insertions(+), 9 deletions(-)
>
> diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
> index bf5779b6543..6e387fd9a61 100644
> --- a/gcc/omp-low.cc
> +++ b/gcc/omp-low.cc
> @@ -13656,26 +13656,30 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
> new_var = lookup_decl (var, ctx);
> new_var = DECL_VALUE_EXPR (new_var);
> tree v = new_var;
> + tree v2 = var;
> + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_PTR
> + || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_USE_DEVICE_ADDR)
> + {
> + v2 = maybe_lookup_decl_in_outer_ctx (var, ctx);
> + if (DECL_HAS_VALUE_EXPR_P (v2))
> + v2 = DECL_VALUE_EXPR (v2);
I don't understand the above 2 lines, why do you need that?
Regardless whether v2 has DECL_VALUE_EXPR or not, the type of the
DECL_VALUE_EXPR (v2) and v2 should be the same, build_fold_indirect_ref
should work on both and then v2 is only used as second operand of
gimplify_assign, where the gimplifier makes sure to handle DECL_VALUE_EXPR
correctly. I certainly don't see any difference in the *.omplower dump
if I comment out the above 2 lines.
Otherwise LGTM, so if the 2 lines aren't needed, please also drop the
{}s around v2 = maybe_lookup_decl_in_outer_ctx (var, ctx); and reindent.
> + }
>
> if (is_ref)
> {
> - var = build_fold_indirect_ref (var);
> - gimplify_expr (&var, &assign_body, NULL, is_gimple_val,
> - fb_rvalue);
> - v = create_tmp_var_raw (TREE_TYPE (var), get_name (var));
> + v2 = build_fold_indirect_ref (v2);
> + v = create_tmp_var_raw (TREE_TYPE (v2), get_name (var));
> gimple_add_tmp_var (v);
> TREE_ADDRESSABLE (v) = 1;
> - gimple_seq_add_stmt (&assign_body,
> - gimple_build_assign (v, var));
> + gimplify_assign (v, v2, &assign_body);
> tree rhs = build_fold_addr_expr (v);
> gimple_seq_add_stmt (&assign_body,
> gimple_build_assign (new_var, rhs));
> }
> else
> - gimple_seq_add_stmt (&assign_body,
> - gimple_build_assign (new_var, var));
> + gimplify_assign (new_var, v2, &assign_body);
>
> - tree v2 = lang_hooks.decls.omp_array_data (unshare_expr (v), false);
> + v2 = lang_hooks.decls.omp_array_data (unshare_expr (v), false);
> gcc_assert (v2);
> gimplify_expr (&x, &assign_body, NULL, is_gimple_val, fb_rvalue);
> gimple_seq_add_stmt (&assign_body,
Jakub
next prev parent reply other threads:[~2022-05-04 12:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 13:19 Tobias Burnus
2022-05-04 12:03 ` Jakub Jelinek [this message]
2022-05-04 16:38 ` Tobias Burnus
2022-05-10 12:56 ` [Patch] OpenMP: Fix use_device_{addr, ptr} " Thomas Schwinge
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=YnJrmRQpbmmVhJ/1@tucnak \
--to=jakub@redhat.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--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).