This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix handling of OpenMP implicit linear/lastprivate clauses (PR middle-end/70680)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 20 Apr 2016 03:48:24 +0200
- Subject: [committed] Fix handling of OpenMP implicit linear/lastprivate clauses (PR middle-end/70680)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcases show incorrect handling of implicit linear or
lastprivate clauses on the #pragma omp simd iterators, if the vars aren't
private in the outer context and they aren't in combined constructs, they
should be noticed in the outer context.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk,
queued up for 6 branch after 6.1 is released.
2016-04-19 Jakub Jelinek <jakub@redhat.com>
PR middle-end/70680
* gimplify.c (gimplify_omp_for): Call omp_notice_variable for
implicitly linear or lastprivate iterator on the outer context.
* testsuite/libgomp.c/pr70680-1.c: New test.
* testsuite/libgomp.c/pr70680-2.c: New test.
--- gcc/gimplify.c.jj 2016-04-15 18:04:42.000000000 +0200
+++ gcc/gimplify.c 2016-04-19 20:03:19.347936293 +0200
@@ -8785,7 +8785,10 @@ gimplify_omp_for (tree *expr_p, gimple_s
decl, false))
;
else if (outer->region_type != ORT_COMBINED_PARALLEL)
- outer = NULL;
+ {
+ omp_notice_variable (outer, decl, true);
+ outer = NULL;
+ }
if (outer)
{
n = splay_tree_lookup (outer->variables,
@@ -8868,7 +8871,10 @@ gimplify_omp_for (tree *expr_p, gimple_s
decl, false))
;
else if (outer->region_type != ORT_COMBINED_PARALLEL)
- outer = NULL;
+ {
+ omp_notice_variable (outer, decl, true);
+ outer = NULL;
+ }
if (outer)
{
n = splay_tree_lookup (outer->variables,
--- libgomp/testsuite/libgomp.c/pr70680-1.c.jj 2016-04-19 20:13:54.998588014 +0200
+++ libgomp/testsuite/libgomp.c/pr70680-1.c 2016-04-19 20:01:54.000000000 +0200
@@ -0,0 +1,75 @@
+/* PR middle-end/70680 */
+
+int v;
+
+void
+f1 (void)
+{
+ int i = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd
+ for (i = 0; i < 100; i++)
+ ;
+ v = i;
+ }
+ if (i != 100)
+ __builtin_abort ();
+}
+
+void
+f2 (void)
+{
+ int i = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd
+ for (i = 0; i < 100; i++)
+ ;
+ }
+ if (i != 100)
+ __builtin_abort ();
+}
+
+void
+f3 (void)
+{
+ int i = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd linear(i: 1)
+ for (i = 0; i < 100; i++)
+ ;
+ v = i;
+ }
+ if (i != 100)
+ __builtin_abort ();
+}
+
+void
+f4 (void)
+{
+ int i = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd linear(i: 1)
+ for (i = 0; i < 100; i++)
+ ;
+ }
+ if (i != 100)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ f1 ();
+ if (v++ != 100)
+ __builtin_abort ();
+ f2 ();
+ f3 ();
+ if (v++ != 100)
+ __builtin_abort ();
+ f4 ();
+ return 0;
+}
--- libgomp/testsuite/libgomp.c/pr70680-2.c.jj 2016-04-19 20:13:59.570527869 +0200
+++ libgomp/testsuite/libgomp.c/pr70680-2.c 2016-04-19 20:09:02.000000000 +0200
@@ -0,0 +1,79 @@
+/* PR middle-end/70680 */
+
+int v;
+
+void
+f1 (void)
+{
+ int i = 0, j = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ ;
+ v = i + j;
+ }
+ if (i != 10 || j != 10)
+ __builtin_abort ();
+}
+
+void
+f2 (void)
+{
+ int i = 0, j = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd collapse(2)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ ;
+ }
+ if (i != 10 || j != 10)
+ __builtin_abort ();
+}
+
+void
+f3 (void)
+{
+ int i = 0, j = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd collapse(2) lastprivate (i, j)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ ;
+ v = i + j;
+ }
+ if (i != 10 || j != 10)
+ __builtin_abort ();
+}
+
+void
+f4 (void)
+{
+ int i = 0, j = 0;
+#pragma omp task default(shared) if(0)
+ {
+#pragma omp simd collapse(2) lastprivate (i, j)
+ for (i = 0; i < 10; i++)
+ for (j = 0; j < 10; j++)
+ ;
+ }
+ if (i != 10 || j != 10)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ f1 ();
+ if (v++ != 20)
+ __builtin_abort ();
+ f2 ();
+ f3 ();
+ if (v++ != 20)
+ __builtin_abort ();
+ f4 ();
+ return 0;
+}
Jakub