From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Tobias Burnus <tobias@codesourcery.com>
Subject: [committed] nested, openmp: Wrap OMP_CLAUSE_*_GIMPLE_SEQ into GIMPLE_BIND for declare_vars [PR108435]
Date: Thu, 2 Feb 2023 10:00:52 +0100 [thread overview]
Message-ID: <Y9t7xMBKDiGdX3/F@tucnak> (raw)
Hi!
When gimplifying OMP_CLAUSE_{LASTPRIVATE,LINEAR}_STMT, we wrap it always
into a GIMPLE_BIND, but when putting statements directly into
OMP_CLAUSE_{LASTPRIVATE,LINEAR}_GIMPLE_SEQ, we do it only if needed (there
are any temporaries that need to be declared in the sequence).
convert_nonlocal_omp_clauses was relying on the GIMPLE_BIND to be there always
because it called declare_vars on it.
The following patch wraps it into GIMPLE_BIND in tree-nested if we need to
declare_vars on it on demand.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
2023-02-02 Jakub Jelinek <jakub@redhat.com>
PR middle-end/108435
* tree-nested.cc (convert_nonlocal_omp_clauses)
<case OMP_CLAUSE_LASTPRIVATE>: If info->new_local_var_chain and
*seq is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND
before calling declare_vars.
(convert_nonlocal_omp_clauses) <case OMP_CLAUSE_LINEAR>: Merge
with the OMP_CLAUSE_LASTPRIVATE handling except for whether
seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause)
or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause).
* gcc.dg/gomp/pr108435.c: New test.
--- gcc/tree-nested.cc.jj 2023-01-02 09:32:40.110029184 +0100
+++ gcc/tree-nested.cc 2023-02-01 16:22:33.272248502 +0100
@@ -1566,29 +1566,29 @@ convert_nonlocal_omp_clauses (tree *pcla
break;
case OMP_CLAUSE_LASTPRIVATE:
- {
- tree save_local_var_chain = info->new_local_var_chain;
- info->new_local_var_chain = NULL;
- gimple_seq *seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause);
- walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info, seq);
- if (info->new_local_var_chain)
- declare_vars (info->new_local_var_chain,
- gimple_seq_first_stmt (*seq), false);
- info->new_local_var_chain = save_local_var_chain;
- }
- break;
-
case OMP_CLAUSE_LINEAR:
{
tree save_local_var_chain = info->new_local_var_chain;
info->new_local_var_chain = NULL;
- gimple_seq *seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause);
+ gimple_seq *seq;
+ if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_LASTPRIVATE)
+ seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause);
+ else
+ seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause);
walk_body (convert_nonlocal_reference_stmt,
convert_nonlocal_reference_op, info, seq);
if (info->new_local_var_chain)
- declare_vars (info->new_local_var_chain,
- gimple_seq_first_stmt (*seq), false);
+ {
+ gimple *g = gimple_seq_first_stmt (*seq);
+ if (gimple_code (g) != GIMPLE_BIND)
+ {
+ g = gimple_build_bind (NULL_TREE, *seq, NULL_TREE);
+ *seq = NULL;
+ gimple_seq_add_stmt_without_update (seq, g);
+ }
+ declare_vars (info->new_local_var_chain,
+ gimple_seq_first_stmt (*seq), false);
+ }
info->new_local_var_chain = save_local_var_chain;
}
break;
--- gcc/testsuite/gcc.dg/gomp/pr108435.c.jj 2023-02-01 16:24:56.180152165 +0100
+++ gcc/testsuite/gcc.dg/gomp/pr108435.c 2023-02-01 16:24:36.150445983 +0100
@@ -0,0 +1,18 @@
+/* PR middle-end/108435 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp" } */
+
+int
+main ()
+{
+ int i, j;
+ void
+ bar (void)
+ {
+ #pragma omp for simd collapse(2)
+ for (i = 1; i <= 16; i++)
+ for (j = 1; j <= 16; j++)
+ ;
+ }
+ bar ();
+}
Jakub
reply other threads:[~2023-02-02 9:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Y9t7xMBKDiGdX3/F@tucnak \
--to=jakub@redhat.com \
--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).