omp-low.c (lower_omp_1): Look through ordered...

* omp-low.c (lower_omp_1) <case GIMPLE_ASSIGN>: 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
This commit is contained in:
Jakub Jelinek 2019-05-27 23:31:40 +02:00 committed by Jakub Jelinek
parent fcfb80325f
commit 36c7a3fff9
4 changed files with 75 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2019-05-27 Jakub Jelinek <jakub@redhat.com>
* omp-low.c (lower_omp_1) <case GIMPLE_ASSIGN>: Look through ordered,
critical, taskgroup and section regions when looking for a region
with non-NULL lastprivate_conditional_map.
2019-05-27 Uroš Bizjak <ubizjak@gmail.com>
* config/i386/i386.c (ix86_gen_add3): Remove indirect function.

View File

@ -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 <gomp_for *> (ctx->stmt));
= gimple_omp_for_clauses (as_a <gomp_for *> (up->stmt));
tree c = omp_find_clause (clauses, OMP_CLAUSE__CONDTEMP_);
c = omp_find_clause (OMP_CLAUSE_CHAIN (c),
OMP_CLAUSE__CONDTEMP_);

View File

@ -1,5 +1,7 @@
2019-05-27 Jakub Jelinek <jakub@redhat.com>
* 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

View File

@ -0,0 +1,57 @@
/* { dg-do run } */
/* { dg-require-effective-target tls_runtime } */
/* { dg-additional-options "-std=gnu99" {target c } } */
#include <omp.h>
#include <stdlib.h>
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;
}