diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2020-09-16 16:23:13 +0200 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2020-09-16 16:23:13 +0200 |
commit | 91347c3bbf788ede4af89f46206991c47fa8aceb (patch) | |
tree | db8eee921a878bd0b338c07697193f38eae5aec5 /gcc/fortran/trans-openmp.c | |
parent | 2b7147e48564679d53b3c6629714991c5506d614 (diff) | |
download | gcc-91347c3bbf788ede4af89f46206991c47fa8aceb.zip gcc-91347c3bbf788ede4af89f46206991c47fa8aceb.tar.gz gcc-91347c3bbf788ede4af89f46206991c47fa8aceb.tar.bz2 |
Fortran: OpenMP - fix simd with (last)private (PR97061)
gcc/fortran/ChangeLog:
PR fortran/97061
* trans-openmp.c (gfc_trans_omp_do): Handle simd with (last)private.
gcc/testsuite/ChangeLog:
PR fortran/97061
* gfortran.dg/gomp/openmp-simd-6.f90: New test.
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r-- | gcc/fortran/trans-openmp.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 9ec0df2..378088a 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -4401,20 +4401,29 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, if (clauses) { gfc_omp_namelist *n = NULL; - if (op != EXEC_OMP_DISTRIBUTE) - for (n = clauses->lists[(op == EXEC_OMP_SIMD && collapse == 1) - ? OMP_LIST_LINEAR : OMP_LIST_LASTPRIVATE]; + if (op == EXEC_OMP_SIMD && collapse == 1) + for (n = clauses->lists[OMP_LIST_LINEAR]; n != NULL; n = n->next) if (code->ext.iterator->var->symtree->n.sym == n->sym) - break; - if (n != NULL) - dovar_found = 1; - else if (n == NULL && op != EXEC_OMP_SIMD) + { + dovar_found = 3; + break; + } + if (n == NULL && op != EXEC_OMP_DISTRIBUTE) + for (n = clauses->lists[OMP_LIST_LASTPRIVATE]; + n != NULL; n = n->next) + if (code->ext.iterator->var->symtree->n.sym == n->sym) + { + dovar_found = 2; + break; + } + if (n == NULL) for (n = clauses->lists[OMP_LIST_PRIVATE]; n != NULL; n = n->next) if (code->ext.iterator->var->symtree->n.sym == n->sym) - break; - if (n != NULL) - dovar_found++; + { + dovar_found = 1; + break; + } } /* Evaluate all the expressions in the iterator. */ @@ -4512,7 +4521,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, if (orig_decls) TREE_VEC_ELT (orig_decls, i) = dovar_decl; - if (dovar_found == 2 + if (dovar_found == 3 && op == EXEC_OMP_SIMD && collapse == 1 && !simple) @@ -4536,7 +4545,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } if (!simple) - dovar_found = 2; + dovar_found = 3; } else if (!dovar_found && !simple) { @@ -4544,7 +4553,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, OMP_CLAUSE_DECL (tmp) = dovar_decl; omp_clauses = gfc_trans_add_clause (tmp, omp_clauses); } - if (dovar_found == 2) + if (dovar_found > 1) { tree c = NULL; @@ -4612,7 +4621,7 @@ gfc_trans_omp_do (gfc_code *code, gfc_exec_op op, stmtblock_t *pblock, } if (!simple) { - if (op != EXEC_OMP_SIMD) + if (op != EXEC_OMP_SIMD || dovar_found == 1) tmp = build_omp_clause (input_location, OMP_CLAUSE_PRIVATE); else if (collapse == 1) { |