This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Don't optimize away OpenMP tasks with empty bodies, but with depend clauses (PR libgomp/80394)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 11 Apr 2017 19:18:33 +0200
- Subject: [committed] Don't optimize away OpenMP tasks with empty bodies, but with depend clauses (PR libgomp/80394)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 181EF804F2
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 181EF804F2
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Tasks that have depend clauses can't be optimized away even if they
have empty body, the depend clause still has important side-effects.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, queued for backporting.
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.
--- gcc/omp-low.c.jj 2017-03-29 07:11:14.000000000 +0200
+++ gcc/omp-low.c 2017-04-11 15:17:32.608077934 +0200
@@ -1857,9 +1857,11 @@ scan_omp_task (gimple_stmt_iterator *gsi
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))
+ && !omp_find_clause (gimple_omp_task_clauses (stmt), OMP_CLAUSE_DEPEND))
{
gsi_replace (gsi, gimple_build_nop (), false);
return;
--- libgomp/testsuite/libgomp.c/pr80394.c.jj 2017-04-11 15:14:18.783514493 +0200
+++ libgomp/testsuite/libgomp.c/pr80394.c 2017-04-11 15:13:56.460795111 +0200
@@ -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;
+}
Jakub