]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR libgomp/80394 (Empty OpenMP task is wrongly removed when optimizing)
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 08:25:50 +0000 (10:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 08:25:50 +0000 (10:25 +0200)
Backported from mainline
2017-04-11  Jakub Jelinek  <jakub@redhat.com>

PR libgomp/80394
* omp-low.c (scan_omp_task): Don't optimize away empty tasks
if they have any depend clauses.

* testsuite/libgomp.c/pr80394.c: New test.

From-SVN: r248671

gcc/ChangeLog
gcc/omp-low.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.c/pr80394.c [new file with mode: 0644]

index 32e6d75a790f038baa8c7790c23dcc3ec2ff7fdb..24ddc3397a5ca7427d9fbc928b4eeed080bb65a4 100644 (file)
@@ -1,6 +1,12 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-04-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libgomp/80394
+       * omp-low.c (scan_omp_task): Don't optimize away empty tasks
+       if they have any depend clauses.
+
        2017-04-04  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/80286
index 945b9c733d6a58b924a68a3de102317789d947ff..907a728417b8ba3f88089c9a180df3677516bf6b 100644 (file)
@@ -2378,9 +2378,11 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx)
   tree name, t;
   gomp_task *stmt = as_a <gomp_task *> (gsi_stmt (*gsi));
 
-  /* Ignore task directives with empty bodies.  */
+  /* Ignore task directives with empty bodies, unless they have depend
+     clause.  */
   if (optimize > 0
-      && empty_body_p (gimple_omp_body (stmt)))
+      && empty_body_p (gimple_omp_body (stmt))
+      && !find_omp_clause (gimple_omp_task_clauses (stmt), OMP_CLAUSE_DEPEND))
     {
       gsi_replace (gsi, gimple_build_nop (), false);
       return;
index bae1441dabf186d0013681c022dfd08d8c0f9c27..b602cf16998e57302781880041e3c4be13017f8d 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-04-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR libgomp/80394
+       * testsuite/libgomp.c/pr80394.c: New test.
+
        2017-03-30  Jakub Jelinek  <jakub@redhat.com>
 
        * env.c (initialize_env): Initialize stacksize to 0.
diff --git a/libgomp/testsuite/libgomp.c/pr80394.c b/libgomp/testsuite/libgomp.c/pr80394.c
new file mode 100644 (file)
index 0000000..6c5a740
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR libgomp/80394 */
+
+int
+main ()
+{
+  int x = 0;
+  #pragma omp parallel shared(x)
+  #pragma omp single
+  {
+    #pragma omp task depend(inout: x)
+    {
+      for (int i = 0; i < 100000; i++)
+        asm volatile ("" : : : "memory");
+      x += 5;
+    }
+    #pragma omp task if (0) depend(inout: x)
+    ;
+    if (x != 5)
+      __builtin_abort ();
+  }
+  return 0;
+}