* [committed] Don't optimize away OpenMP tasks with empty bodies, but with depend clauses (PR libgomp/80394)
@ 2017-04-11 17:18 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2017-04-11 17:18 UTC (permalink / raw)
To: gcc-patches
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-04-11 17:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 17:18 [committed] Don't optimize away OpenMP tasks with empty bodies, but with depend clauses (PR libgomp/80394) Jakub Jelinek
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).