public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-10] openmp: Handle clauses with gimple sequences in convert_nonlocal_omp_clauses properly
@ 2020-09-01 9:59 Tobias Burnus
0 siblings, 0 replies; 2+ messages in thread
From: Tobias Burnus @ 2020-09-01 9:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:cbde60ab63e7b94a664fb8fef8640d0d6a63b13c
commit cbde60ab63e7b94a664fb8fef8640d0d6a63b13c
Author: Jakub Jelinek <jakub@redhat.com>
Date: Sat Aug 8 11:10:30 2020 +0200
openmp: Handle clauses with gimple sequences in convert_nonlocal_omp_clauses properly
If the walk_body on the various sequences of reduction, lastprivate and/or linear
clauses needs to create a temporary variable, we should declare that variable
in that sequence rather than outside, where it would need to be privatized inside of
the construct.
2020-08-08 Jakub Jelinek <jakub@redhat.com>
PR fortran/93553
* tree-nested.c (convert_nonlocal_omp_clauses): For
OMP_CLAUSE_REDUCTION, OMP_CLAUSE_LASTPRIVATE and OMP_CLAUSE_LINEAR
save info->new_local_var_chain around walks of the clause gimple
sequences and declare_vars if needed into the sequence.
2020-08-08 Tobias Burnus <tobias@codesourcery.com>
PR fortran/93553
* testsuite/libgomp.fortran/pr93553.f90: New test.
(cherry picked from commit 676b5525e8333005bdc1c596ed086f1da27a450f)
Diff:
---
gcc/tree-nested.c | 46 +++++++++++++++++++++------
libgomp/testsuite/libgomp.fortran/pr93553.f90 | 21 ++++++++++++
2 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 6f696da5332..fd2165b8bdb 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1422,12 +1422,22 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
if (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
DECL_CONTEXT (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
= info->context;
+ tree save_local_var_chain = info->new_local_var_chain;
+ info->new_local_var_chain = NULL;
+ gimple_seq *seq = &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (clause);
walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (clause));
+ 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 = NULL;
+ seq = &OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (clause);
walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (clause));
+ 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;
DECL_CONTEXT (OMP_CLAUSE_REDUCTION_PLACEHOLDER (clause))
= old_context;
if (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
@@ -1437,15 +1447,31 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
break;
case OMP_CLAUSE_LASTPRIVATE:
- walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause));
+ {
+ 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:
- walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause));
+ {
+ 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);
+ 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;
default:
diff --git a/libgomp/testsuite/libgomp.fortran/pr93553.f90 b/libgomp/testsuite/libgomp.fortran/pr93553.f90
new file mode 100644
index 00000000000..5d6f10febed
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr93553.f90
@@ -0,0 +1,21 @@
+program p
+ implicit none
+ integer :: x(8) = 0
+ call sub(x)
+end
+subroutine sub(x)
+ implicit none
+ integer i
+ integer :: x(8)
+ integer :: c(8) = [(11*i, i=1,8)]
+ call s
+ if (any (x /= c)) stop 1
+contains
+ subroutine s
+ integer :: i
+ !$omp parallel do reduction(+:x)
+ do i = 1, 8
+ x(i) = c(i)
+ end do
+ end
+end
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gcc/devel/omp/gcc-10] openmp: Handle clauses with gimple sequences in convert_nonlocal_omp_clauses properly
@ 2020-08-18 19:08 Kwok Yeung
0 siblings, 0 replies; 2+ messages in thread
From: Kwok Yeung @ 2020-08-18 19:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:ed0eb7b607064170585be2f42c34e6ffc51b0896
commit ed0eb7b607064170585be2f42c34e6ffc51b0896
Author: Kwok Cheung Yeung <kcy@codesourcery.com>
Date: Tue Aug 18 08:55:21 2020 -0700
openmp: Handle clauses with gimple sequences in convert_nonlocal_omp_clauses properly
This is a backport from master of commit
676b5525e8333005bdc1c596ed086f1da27a450f.
If the walk_body on the various sequences of reduction, lastprivate and/or linear
clauses needs to create a temporary variable, we should declare that variable
in that sequence rather than outside, where it would need to be privatized inside of
the construct.
2020-08-08 Jakub Jelinek <jakub@redhat.com>
PR fortran/93553
* tree-nested.c (convert_nonlocal_omp_clauses): For
OMP_CLAUSE_REDUCTION, OMP_CLAUSE_LASTPRIVATE and OMP_CLAUSE_LINEAR
save info->new_local_var_chain around walks of the clause gimple
sequences and declare_vars if needed into the sequence.
2020-08-08 Tobias Burnus <tobias@codesourcery.com>
PR fortran/93553
* testsuite/libgomp.fortran/pr93553.f90: New test.
Diff:
---
gcc/ChangeLog.omp | 11 +++++++
gcc/tree-nested.c | 46 +++++++++++++++++++++------
libgomp/ChangeLog.omp | 8 +++++
libgomp/testsuite/libgomp.fortran/pr93553.f90 | 21 ++++++++++++
4 files changed, 76 insertions(+), 10 deletions(-)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 34622a3bfa1..063eda3da5e 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,14 @@
+2020-08-18 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ Backport from mainline
+ 2020-08-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/93553
+ * tree-nested.c (convert_nonlocal_omp_clauses): For
+ OMP_CLAUSE_REDUCTION, OMP_CLAUSE_LASTPRIVATE and OMP_CLAUSE_LINEAR
+ save info->new_local_var_chain around walks of the clause gimple
+ sequences and declare_vars if needed into the sequence.
+
2020-07-30 Julian Brown <julian@codesourcery.com>
* config/gcn/gcn-tree.c (gcn_goacc_get_worker_red_decl): Do not
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 7476a3a3def..e42f0b6a2d2 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1424,12 +1424,22 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
if (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
DECL_CONTEXT (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
= info->context;
+ tree save_local_var_chain = info->new_local_var_chain;
+ info->new_local_var_chain = NULL;
+ gimple_seq *seq = &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (clause);
walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_REDUCTION_GIMPLE_INIT (clause));
+ 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 = NULL;
+ seq = &OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (clause);
walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_REDUCTION_GIMPLE_MERGE (clause));
+ 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;
DECL_CONTEXT (OMP_CLAUSE_REDUCTION_PLACEHOLDER (clause))
= old_context;
if (OMP_CLAUSE_REDUCTION_DECL_PLACEHOLDER (clause))
@@ -1439,15 +1449,31 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
break;
case OMP_CLAUSE_LASTPRIVATE:
- walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause));
+ {
+ 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:
- walk_body (convert_nonlocal_reference_stmt,
- convert_nonlocal_reference_op, info,
- &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause));
+ {
+ 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);
+ 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;
default:
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 6c3f695ba4e..4601eae2af4 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2020-08-18 Kwok Cheung Yeung <kcy@codesourcery.com>
+
+ Backport from mainline
+ 2020-08-08 Tobias Burnus <tobias@codesourcery.com>
+
+ PR fortran/93553
+ * testsuite/libgomp.fortran/pr93553.f90: New test.
+
2020-08-18 Kwok Cheung Yeung <kcy@codesourcery.com>
Backport from mainline
diff --git a/libgomp/testsuite/libgomp.fortran/pr93553.f90 b/libgomp/testsuite/libgomp.fortran/pr93553.f90
new file mode 100644
index 00000000000..5d6f10febed
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr93553.f90
@@ -0,0 +1,21 @@
+program p
+ implicit none
+ integer :: x(8) = 0
+ call sub(x)
+end
+subroutine sub(x)
+ implicit none
+ integer i
+ integer :: x(8)
+ integer :: c(8) = [(11*i, i=1,8)]
+ call s
+ if (any (x /= c)) stop 1
+contains
+ subroutine s
+ integer :: i
+ !$omp parallel do reduction(+:x)
+ do i = 1, 8
+ x(i) = c(i)
+ end do
+ end
+end
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-01 9:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-01 9:59 [gcc/devel/omp/gcc-10] openmp: Handle clauses with gimple sequences in convert_nonlocal_omp_clauses properly Tobias Burnus
-- strict thread matches above, loose matches on Subject: below --
2020-08-18 19:08 Kwok Yeung
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).