From 36c7a3fff99326a1dd45f495ee8e1b6bfd6cf9f5 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 27 May 2019 23:31:40 +0200 Subject: [PATCH] omp-low.c (lower_omp_1): Look through ordered... * omp-low.c (lower_omp_1) : Look through ordered, critical, taskgroup and section regions when looking for a region with non-NULL lastprivate_conditional_map. * testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c: New test. From-SVN: r271672 --- gcc/ChangeLog | 6 ++ gcc/omp-low.c | 13 ++++- libgomp/ChangeLog | 2 + .../lastprivate-conditional-3.c | 57 +++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6f75ae5096..ce0004358ce 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-05-27 Jakub Jelinek + + * omp-low.c (lower_omp_1) : Look through ordered, + critical, taskgroup and section regions when looking for a region + with non-NULL lastprivate_conditional_map. + 2019-05-27 Uroš Bizjak * config/i386/i386.c (ix86_gen_add3): Remove indirect function. diff --git a/gcc/omp-low.c b/gcc/omp-low.c index faab5d38428..db9f5047c72 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -10627,14 +10627,21 @@ lower_omp_1 (gimple_stmt_iterator *gsi_p, omp_context *ctx) goto regimplify; case GIMPLE_ASSIGN: - if (ctx && ctx->lastprivate_conditional_map) + for (omp_context *up = ctx; up; up = up->outer) { + if (gimple_code (up->stmt) == GIMPLE_OMP_ORDERED + || gimple_code (up->stmt) == GIMPLE_OMP_CRITICAL + || gimple_code (up->stmt) == GIMPLE_OMP_TASKGROUP + || gimple_code (up->stmt) == GIMPLE_OMP_SECTION) + continue; + else if (!up->lastprivate_conditional_map) + break; tree lhs = get_base_address (gimple_assign_lhs (stmt)); if (DECL_P (lhs)) - if (tree *v = ctx->lastprivate_conditional_map->get (lhs)) + if (tree *v = up->lastprivate_conditional_map->get (lhs)) { tree clauses - = gimple_omp_for_clauses (as_a (ctx->stmt)); + = gimple_omp_for_clauses (as_a (up->stmt)); tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_); c = omp_find_clause (OMP_CLAUSE_CHAIN (c), OMP_CLAUSE__CONDTEMP_); diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 73bc23e80d0..33906ededc7 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,7 @@ 2019-05-27 Jakub Jelinek + * testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c: New test. + PR libgomp/90641 * work.c (gomp_init_work_share): Instead of aligning final ordered value to multiples of long long alignment, align to that the diff --git a/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c new file mode 100644 index 00000000000..6c4370abaa3 --- /dev/null +++ b/libgomp/testsuite/libgomp.c-c++-common/lastprivate-conditional-3.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-additional-options "-std=gnu99" {target c } } */ + +#include +#include + +int r, s, u, v, t; +int *x; + +void +foo (int *a) +{ + int i; + long long j; + #pragma omp for lastprivate (conditional: u, x) ordered + for (i = 15; i < 64; i++) + { + #pragma omp critical + { + if ((a[i] % 5) == 3) + u = i; + } + #pragma omp ordered + { + if ((a[i] % 7) == 2) + x = &a[i]; + } + } + #pragma omp for lastprivate (conditional: v) reduction (+:r, s) schedule (nonmonotonic: static) reduction (task, +: t) + for (i = -3; i < 119; i += 2) + { + ++s; + #pragma omp taskgroup + { + #pragma omp task in_reduction (+: t) + ++t; + if ((a[i + 4] % 11) == 9) + v = i; + else + ++r; + } + } +} + +int +main () +{ + int a[128], i; + for (i = 0; i < 128; i++) + a[i] = i; + #pragma omp parallel + foo (a); + if (u != 63 || v != 115 || x != &a[58] || r != 55 || s != 61 || t != 61) + abort (); + return 0; +} -- 2.30.2