public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167]
@ 2021-06-23 10:06 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-06-23 10:06 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:235d6eda48dc1e09f5b8daf93006fcc2256cbaae
commit 235d6eda48dc1e09f5b8daf93006fcc2256cbaae
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Jun 23 11:25:46 2021 +0200
openmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167]
The following testcase FAILs, because the UDR combiner is invoked incorrectly.
lower_omp_rec_clauses expects that when it sets
DECL_VALUE_EXPR/DECL_HAS_VALUE_EXPR_P
for both the placeholder and the var that everything will be properly
regimplified, but as the variable in question is a PARM_DECL rather than
VAR_DECL, lower_omp_regimplify_p doesn't say that it should be regimplified
and so it is not.
2021-06-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/101167
* omp-low.c (lower_omp_regimplify_p): Regimplify also PARM_DECLs
and RESULT_DECLs that have DECL_HAS_VALUE_EXPR_P set.
* testsuite/libgomp.c-c++-common/task-reduction-15.c: New test.
(cherry picked from commit 679506c3830ea1a93c755413609bfac3538e2cbd)
Diff:
---
gcc/ChangeLog.omp | 9 ++++
gcc/omp-low.c | 4 +-
libgomp/ChangeLog.omp | 8 +++
.../libgomp.c-c++-common/task-reduction-15.c | 61 ++++++++++++++++++++++
4 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 418f7858fb7..dd29382c899 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-06-23 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-06-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/101167
+ * omp-low.c (lower_omp_regimplify_p): Regimplify also PARM_DECLs
+ and RESULT_DECLs that have DECL_HAS_VALUE_EXPR_P set.
+
2021-06-22 Marcel Vollweiler <marcel@codesourcery.com>
gcc/configure.ac: fix register issue for global_load assembler functions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index dca154a56a8..36160f71743 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -13979,7 +13979,9 @@ lower_omp_regimplify_p (tree *tp, int *walk_subtrees,
tree t = *tp;
/* Any variable with DECL_VALUE_EXPR needs to be regimplified. */
- if (VAR_P (t) && data == NULL && DECL_HAS_VALUE_EXPR_P (t))
+ if ((VAR_P (t) || TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
+ && data == NULL
+ && DECL_HAS_VALUE_EXPR_P (t))
return t;
if (task_shared_vars
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index d4d93c865f2..6573b92c7bc 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-06-23 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-06-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/101167
+ * testsuite/libgomp.c-c++-common/task-reduction-15.c: New test.
+
2021-06-15 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/task-reduction-15.c b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-15.c
new file mode 100644
index 00000000000..5e87139ccfb
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-15.c
@@ -0,0 +1,61 @@
+/* PR middle-end/101167 */
+
+extern
+#ifdef __cplusplus
+"C"
+#endif
+void abort (void);
+
+struct S { int a, b, c[2]; };
+
+void
+init (struct S *x)
+{
+ x->a = 0;
+ x->b = 0;
+ x->c[0] = 0;
+ x->c[1] = 0;
+}
+
+void
+merge (struct S *x, struct S *y)
+{
+ x->a += y->a;
+ x->b += y->b;
+}
+
+#pragma omp declare reduction (+: struct S : merge (&omp_out, &omp_in)) initializer (init (&omp_priv))
+
+void
+foo (struct S x)
+{
+ #pragma omp taskgroup task_reduction (+: x)
+ {
+ #pragma omp task in_reduction (+: x)
+ {
+ x.a++;
+ x.b++;
+ }
+ #pragma omp task in_reduction (+: x)
+ {
+ x.a += 4;
+ x.b += 14;
+ }
+ #pragma omp task in_reduction (+: x)
+ {
+ x.a += 9;
+ x.b += 19;
+ }
+ }
+ if (x.a != 56 || x.b != 86)
+ abort ();
+}
+
+int
+main ()
+{
+ struct S x = { 42, 52 };
+ #pragma omp parallel master num_threads(3)
+ foo (x);
+ return 0;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-23 10:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 10:06 [gcc/devel/omp/gcc-11] openmp: Fix up *_reduction clause handling with UDRs on PARM_DECLs [PR101167] Tobias Burnus
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).