omp-expand.c (expand_omp_for_static_nochunk, [...]): For nowait worksharing loop...
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jul 2019 04:51:45 +0000 (06:51 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jul 2019 04:51:45 +0000 (06:51 +0200)
* omp-expand.c (expand_omp_for_static_nochunk,
expand_omp_for_static_chunk): For nowait worksharing loop with
conditional lastprivate clause(s), emit GOMP_loop_end_nowait call
at the end.

* c-c++-common/gomp/lastprivate-conditional-5.c: New test.

From-SVN: r272956

gcc/ChangeLog
gcc/omp-expand.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/gomp/lastprivate-conditional-5.c [new file with mode: 0644]

index c7fed52b573ff746d1cb39e94baa652142b85c09..58937b0496b16c52a698ec4ab9d38e14f24de5ca 100644 (file)
@@ -1,3 +1,10 @@
+2019-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+       * omp-expand.c (expand_omp_for_static_nochunk,
+       expand_omp_for_static_chunk): For nowait worksharing loop with
+       conditional lastprivate clause(s), emit GOMP_loop_end_nowait call
+       at the end.
+
 2019-07-02  Joern Rennecke  <joern.rennecke@riscy-ip.com>
 
        PR testsuite/91065
index 69344f449c9fea9030ea181de637deb274b4ee50..6902425a3d6ccdcbee184bafbd9e230ceb5fe720 100644 (file)
@@ -4039,6 +4039,12 @@ expand_omp_for_static_nochunk (struct omp_region *region,
       else
        gsi_insert_after (&gsi, omp_build_barrier (t), GSI_SAME_STMT);
     }
+  else if (fd->have_pointer_condtemp)
+    {
+      tree fn = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT);
+      gcall *g = gimple_build_call (fn, 0);
+      gsi_insert_after (&gsi, g, GSI_SAME_STMT);
+    }
   gsi_remove (&gsi, true);
 
   /* Connect all the blocks.  */
@@ -4696,6 +4702,12 @@ expand_omp_for_static_chunk (struct omp_region *region,
       else
        gsi_insert_after (&gsi, omp_build_barrier (t), GSI_SAME_STMT);
     }
+  else if (fd->have_pointer_condtemp)
+    {
+      tree fn = builtin_decl_explicit (BUILT_IN_GOMP_LOOP_END_NOWAIT);
+      gcall *g = gimple_build_call (fn, 0);
+      gsi_insert_after (&gsi, g, GSI_SAME_STMT);
+    }
   gsi_remove (&gsi, true);
 
   /* Connect the new blocks.  */
index 9bb683facbd8495d5cff429518e55a042fcd5149..5abcceec60164c0c60e9a554313450d6abb47c05 100644 (file)
@@ -1,3 +1,7 @@
+2019-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-c++-common/gomp/lastprivate-conditional-5.c: New test.
+
 2019-07-02  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/90883
diff --git a/gcc/testsuite/c-c++-common/gomp/lastprivate-conditional-5.c b/gcc/testsuite/c-c++-common/gomp/lastprivate-conditional-5.c
new file mode 100644 (file)
index 0000000..51f6b30
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp -fdump-tree-ompexp" } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_start " 3 "ompexp" } } */
+/* { dg-final { scan-tree-dump-times "GOMP_loop_end_nowait " 3 "ompexp" } } */
+
+int r;
+
+void
+foo (int *a)
+{
+  #pragma omp for nowait lastprivate(conditional: r)
+  for (int i = 0; i < 64; ++i)
+    if (a[i])
+      r = a[i];
+}
+
+void
+bar (int *a)
+{
+  #pragma omp for nowait lastprivate(conditional: r) schedule (static, 4)
+  for (int i = 0; i < 64; ++i)
+    if (a[i])
+      r = a[i];
+}
+
+void
+baz (int *a)
+{
+  #pragma omp for nowait lastprivate(conditional: r) schedule (runtime)
+  for (int i = 0; i < 64; ++i)
+    if (a[i])
+      r = a[i];
+}