From 2412ae84cfbcd52c56d2604e846cfa5c0da0321d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 11 Apr 2017 17:15:47 +0000 Subject: 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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@246849 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/omp-low.c | 6 ++++-- libgomp/ChangeLog | 5 +++++ libgomp/testsuite/libgomp.c/pr80394.c | 22 ++++++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 libgomp/testsuite/libgomp.c/pr80394.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4e62a498246..900e58ce58e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-04-11 Jakub Jelinek + + PR libgomp/80394 + * omp-low.c (scan_omp_task): Don't optimize away empty tasks + if they have any depend clauses. + 2017-04-11 Martin Liska PR ipa/80212 diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 253dc856374..22772ba2891 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -1857,9 +1857,11 @@ scan_omp_task (gimple_stmt_iterator *gsi, omp_context *outer_ctx) tree name, t; gomp_task *stmt = as_a (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; diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 5beaaa7cfba..67351ae7d11 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2017-04-11 Jakub Jelinek + + PR libgomp/80394 + * testsuite/libgomp.c/pr80394.c: New test. + 2017-04-04 Jakub Jelinek PR libgomp/79876 diff --git a/libgomp/testsuite/libgomp.c/pr80394.c b/libgomp/testsuite/libgomp.c/pr80394.c new file mode 100644 index 00000000000..6c5a7401851 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/pr80394.c @@ -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; +} -- cgit v1.2.3