re PR c/81887 (pragma omp ordered simd ignored under -fopenmp-simd)

PR c/81887
c-family/
	* c-pragma.c (omp_pragmas): Move "ordered" entry from here to ...
	(omp_pragmas_simd): ... here.
	* c-omp.c (c_finish_omp_ordered): If clauses isn't simd clause alone,
	create new clauses list containing just simd clause.
c/
	* c-parser.c (c_parser_omp_ordered): Handle -fopenmp-simd.
cp/
	* parser.c (cp_parser_omp_ordered): Handle -fopenmp-simd.
fortran/
	* parse.c (decode_omp_directive): Use matchs instead of matcho for
	end ordered and ordered directives, except for ordered depend.  For
	-fopenmp-simd and ordered depend, reject the stmt.
	* trans-openmp.c (gfc_trans_omp_ordered): For -fopenmp-simd ignore
	threads clause and if simd clause isn't present, just translate the
	body.
testsuite/
	* c-c++-common/gomp/pr81887.c: New test.
	* gfortran.dg/gomp/pr81887.f90: New test.

From-SVN: r251585
This commit is contained in:
Jakub Jelinek 2017-09-01 13:25:39 +02:00 committed by Jakub Jelinek
parent 39baa1d35e
commit d2e05fcbda
13 changed files with 192 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR c/81887
* c-pragma.c (omp_pragmas): Move "ordered" entry from here to ...
(omp_pragmas_simd): ... here.
* c-omp.c (c_finish_omp_ordered): If clauses isn't simd clause alone,
create new clauses list containing just simd clause.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>

View file

@ -116,6 +116,10 @@ c_finish_omp_ordered (location_t loc, tree clauses, tree stmt)
tree t = make_node (OMP_ORDERED);
TREE_TYPE (t) = void_type_node;
OMP_ORDERED_BODY (t) = stmt;
if (!flag_openmp /* flag_openmp_simd */
&& (OMP_CLAUSE_CODE (clauses) != OMP_CLAUSE_SIMD
|| OMP_CLAUSE_CHAIN (clauses)))
clauses = build_omp_clause (loc, OMP_CLAUSE_SIMD);
OMP_ORDERED_CLAUSES (t) = clauses;
SET_EXPR_LOCATION (t, loc);
return add_stmt (t);

View file

@ -1277,7 +1277,6 @@ static const struct omp_pragma_def omp_pragmas[] = {
{ "end", PRAGMA_OMP_END_DECLARE_TARGET },
{ "flush", PRAGMA_OMP_FLUSH },
{ "master", PRAGMA_OMP_MASTER },
{ "ordered", PRAGMA_OMP_ORDERED },
{ "section", PRAGMA_OMP_SECTION },
{ "sections", PRAGMA_OMP_SECTIONS },
{ "single", PRAGMA_OMP_SINGLE },
@ -1291,6 +1290,7 @@ static const struct omp_pragma_def omp_pragmas_simd[] = {
{ "declare", PRAGMA_OMP_DECLARE },
{ "distribute", PRAGMA_OMP_DISTRIBUTE },
{ "for", PRAGMA_OMP_FOR },
{ "ordered", PRAGMA_OMP_ORDERED },
{ "parallel", PRAGMA_OMP_PARALLEL },
{ "simd", PRAGMA_OMP_SIMD },
{ "target", PRAGMA_OMP_TARGET },

View file

@ -1,3 +1,8 @@
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR c/81887
* c-parser.c (c_parser_omp_ordered): Handle -fopenmp-simd.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>

View file

@ -15647,6 +15647,11 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context,
if (!strcmp ("depend", p))
{
if (!flag_openmp) /* flag_openmp_simd */
{
c_parser_skip_to_pragma_eol (parser, false);
return false;
}
if (context == pragma_stmt)
{
error_at (loc,
@ -15667,6 +15672,11 @@ c_parser_omp_ordered (c_parser *parser, enum pragma_context context,
tree clauses = c_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK,
"#pragma omp ordered");
if (!flag_openmp /* flag_openmp_simd */
&& omp_find_clause (clauses, OMP_CLAUSE_SIMD) == NULL_TREE)
return false;
c_finish_omp_ordered (loc, clauses,
c_parser_omp_structured_block (parser, if_p));
return true;

View file

@ -1,3 +1,8 @@
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR c/81887
* parser.c (cp_parser_omp_ordered): Handle -fopenmp-simd.
2017-09-01 Marek Polacek <polacek@redhat.com>
PR c++/82040

View file

@ -35301,6 +35301,11 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok,
if (strcmp (p, "depend") == 0)
{
if (!flag_openmp) /* flag_openmp_simd */
{
cp_parser_skip_to_pragma_eol (parser, pragma_tok);
return false;
}
if (context == pragma_stmt)
{
error_at (pragma_tok->location, "%<#pragma omp ordered%> with "
@ -35321,6 +35326,11 @@ cp_parser_omp_ordered (cp_parser *parser, cp_token *pragma_tok,
tree clauses
= cp_parser_omp_all_clauses (parser, OMP_ORDERED_CLAUSE_MASK,
"#pragma omp ordered", pragma_tok);
if (!flag_openmp /* flag_openmp_simd */
&& omp_find_clause (clauses, OMP_CLAUSE_SIMD) == NULL_TREE)
return false;
c_finish_omp_ordered (loc, clauses,
cp_parser_omp_structured_block (parser, if_p));
return true;

View file

@ -1,3 +1,13 @@
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR c/81887
* parse.c (decode_omp_directive): Use matchs instead of matcho for
end ordered and ordered directives, except for ordered depend. For
-fopenmp-simd and ordered depend, reject the stmt.
* trans-openmp.c (gfc_trans_omp_ordered): For -fopenmp-simd ignore
threads clause and if simd clause isn't present, just translate the
body.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>

View file

@ -875,7 +875,7 @@ decode_omp_directive (void)
matcho ("end do", gfc_match_omp_end_nowait, ST_OMP_END_DO);
matchs ("end simd", gfc_match_omp_eos, ST_OMP_END_SIMD);
matcho ("end master", gfc_match_omp_eos, ST_OMP_END_MASTER);
matcho ("end ordered", gfc_match_omp_eos, ST_OMP_END_ORDERED);
matchs ("end ordered", gfc_match_omp_eos, ST_OMP_END_ORDERED);
matchs ("end parallel do simd", gfc_match_omp_eos,
ST_OMP_END_PARALLEL_DO_SIMD);
matcho ("end parallel do", gfc_match_omp_eos, ST_OMP_END_PARALLEL_DO);
@ -929,14 +929,16 @@ decode_omp_directive (void)
matcho ("master", gfc_match_omp_master, ST_OMP_MASTER);
break;
case 'o':
if (flag_openmp && gfc_match ("ordered depend (") == MATCH_YES)
if (gfc_match ("ordered depend (") == MATCH_YES)
{
gfc_current_locus = old_locus;
if (!flag_openmp)
break;
matcho ("ordered", gfc_match_omp_ordered_depend,
ST_OMP_ORDERED_DEPEND);
}
else
matcho ("ordered", gfc_match_omp_ordered, ST_OMP_ORDERED);
matchs ("ordered", gfc_match_omp_ordered, ST_OMP_ORDERED);
break;
case 'p':
matchs ("parallel do simd", gfc_match_omp_parallel_do_simd,

View file

@ -3925,6 +3925,12 @@ gfc_trans_omp_master (gfc_code *code)
static tree
gfc_trans_omp_ordered (gfc_code *code)
{
if (!flag_openmp)
{
if (!code->ext.omp_clauses->simd)
return gfc_trans_code (code->block ? code->block->next : NULL);
code->ext.omp_clauses->threads = 0;
}
tree omp_clauses = gfc_trans_omp_clauses (NULL, code->ext.omp_clauses,
code->loc);
return build2_loc (input_location, OMP_ORDERED, void_type_node,

View file

@ -1,3 +1,9 @@
2017-09-01 Jakub Jelinek <jakub@redhat.com>
PR c/81887
* c-c++-common/gomp/pr81887.c: New test.
* gfortran.dg/gomp/pr81887.f90: New test.
2017-09-01 Marek Polacek <polacek@redhat.com>
PR c++/82040

View file

@ -0,0 +1,61 @@
/* PR c/81887 */
/* { dg-do compile } */
/* { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-gimple" } */
/* { dg-final { scan-tree-dump-times "#pragma omp simd" 2 "gimple" } } */
/* { dg-final { scan-tree-dump-times "#pragma omp ordered simd\[ \t]*\[\n\r]" 2 "gimple" } } */
/* { dg-final { scan-tree-dump-times "#pragma omp" 4 "gimple" } } */
void
f1 (int *x)
{
int i;
#pragma omp simd
for (i = 0; i < 100; i++)
#pragma omp ordered simd
x[i / 2] = i;
}
void
f2 (int *x)
{
int i;
#pragma omp parallel for simd ordered
for (i = 0; i < 100; i++)
#pragma omp ordered threads simd
x[i / 2] = i;
}
void
f3 (int *x)
{
int i;
#pragma omp parallel for ordered
for (i = 0; i < 100; i++)
#pragma omp ordered
x[i / 2] = i;
}
void
f4 (int *x)
{
int i;
#pragma omp parallel for ordered
for (i = 0; i < 100; i++)
#pragma omp ordered threads
x[i / 2] = i;
}
void
f5 (int n, int ***x)
{
int i, j, k;
#pragma omp parallel for ordered(3)
for (i=0; i < n; i++)
for (j=0; j < n; ++j)
for (k=0; k < n; ++k)
{
#pragma omp ordered depend(sink:i-8,j-2,k+2) depend(sink:i, j-1,k) depend(sink:i-4,j-3,k+6) depend(sink:i-6,j-4,k-6)
x[i][j][k] = i + j + k;
#pragma omp ordered depend(source)
}
}

View file

@ -0,0 +1,61 @@
! PR c/81887
! { dg-do compile }
! { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-gimple" }
! { dg-final { scan-tree-dump-times "#pragma omp simd" 2 "gimple" } }
! { dg-final { scan-tree-dump-times "#pragma omp ordered simd\[ \t]*\[\n\r]" 2 "gimple" } }
! { dg-final { scan-tree-dump-times "#pragma omp" 4 "gimple" } }
subroutine f1 (x)
integer :: i, x(100)
!$omp simd
do i = 2, 101
!$omp ordered simd
x(i / 2) = i
!$omp end ordered
end do
end subroutine
subroutine f2 (x)
integer :: i, x(100)
!$omp parallel do simd ordered
do i = 2, 101
!$omp ordered threads simd
x(i / 2) = i
!$omp end ordered
end do
end subroutine
subroutine f3 (x)
integer :: i, x(100)
!$omp parallel do ordered
do i = 2, 101
!$omp ordered
x(i / 2) = i
!$omp end ordered
end do
end subroutine
subroutine f4 (x)
integer :: i, x(100)
!$omp parallel do ordered
do i = 2, 101
!$omp ordered threads
x(i / 2) = i
!$omp end ordered
end do
end subroutine
subroutine f5(x, n)
integer :: i, j, k, n, x(100,100,100)
!$omp parallel do ordered(3)
do i = 1, n
do j = 1, n
do k = 1, n
!$omp ordered depend(sink:i-8,j-2,k+2) depend(sink:i, j-1,k) depend(sink:i-4,j-3,k+6) depend(sink:i-6,j-4,k-6)
x(i, j, k) = i + j + k
!$omp ordered depend(source)
end do
end do
end do
!$omp end parallel do
end subroutine