Ping. For reference, I've attached the patch for gcc7.
Cesar On 05/15/2018 07:11 AM, Cesar Philippidis wrote: > This patch resolves the issue in PR85782, which involves a C++ ICE > caused by OpenACC loops which contain continue statements. The problem > is that genericize_continue_stmt expects a continue label for the loop, > but that wasn't getting set up acc loops. This patch fixes that by > calling genericize_omp_for_stmt for OACC_LOOP statements, because > OACC_LOOP and OMP_FOR statements are almost identical at this point of > parsing. > > I regression tested it on x86_64-linux with nvptx offloading. > > Is this ok for trunk and the stable branches? The patch for the stable > branches is slightly different, because cp_genericize_r uses if > statements to check for statement types instead of a huge switch statement. > > Cesar > > > trunk-pr85782.diff > > > 2018-05-15 Cesar Philippidis <ce...@codesourcery.com> > > PR c++/85782 > > gcc/cp/ > * cp-gimplify.c (cp_genericize_r): Call genericize_omp_for_stmt for > OACC_LOOPs. > > gcc/testsuite/ > * c-c++-common/goacc/pr85782.c: New test. > > libgomp/ > * testsuite/libgomp.oacc-c-c++-common/pr85782.c: New test. > > > diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c > index eda5f05..55aef86 100644 > --- a/gcc/cp/cp-gimplify.c > +++ b/gcc/cp/cp-gimplify.c > @@ -1463,6 +1463,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void > *data) > case OMP_FOR: > case OMP_SIMD: > case OMP_DISTRIBUTE: > + case OACC_LOOP: > genericize_omp_for_stmt (stmt_p, walk_subtrees, data); > break; > > diff --git a/gcc/testsuite/c-c++-common/goacc/pr85782.c > b/gcc/testsuite/c-c++-common/goacc/pr85782.c > new file mode 100644 > index 0000000..f213a24 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/goacc/pr85782.c > @@ -0,0 +1,11 @@ > +/* PR c++/85782 */ > + > +void > +foo () > +{ > + int i; > + > + #pragma acc parallel loop > + for (i = 0; i < 100; i++) > + continue; > +} > diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c > b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c > new file mode 100644 > index 0000000..6f84dfc > --- /dev/null > +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c > @@ -0,0 +1,32 @@ > +/* PR c++/85782 */ > + > +#include <assert.h> > + > +#define N 100 > + > +int > +main () > +{ > + int i, a[N]; > + > + for (i = 0; i < N; i++) > + a[i] = i+1; > + > + #pragma acc parallel loop copy(a) > + for (i = 0; i < N; i++) > + { > + if (i % 2) > + continue; > + a[i] = 0; > + } > + > + for (i = 0; i < N; i++) > + { > + if (i % 2) > + assert (a[i] == i+1); > + else > + assert (a[i] == 0); > + } > + > + return 0; > +} >
2018-05-18 Cesar Philippidis <ce...@codesourcery.com> PR c++/85782 gcc/cp/ * cp-gimplify.c (cp_genericize_r): Call genericize_omp_for_stmt for OACC_LOOPs. gcc/testsuite/ * c-c++-common/goacc/pr85782.c: New test. libgomp/ * testsuite/libgomp.oacc-c-c++-common/pr85782.c: New test. diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 00214e9..4fbb8b5 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -1473,7 +1473,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data) genericize_break_stmt (stmt_p); else if (TREE_CODE (stmt) == OMP_FOR || TREE_CODE (stmt) == OMP_SIMD - || TREE_CODE (stmt) == OMP_DISTRIBUTE) + || TREE_CODE (stmt) == OMP_DISTRIBUTE + || TREE_CODE (stmt) == OACC_LOOP) genericize_omp_for_stmt (stmt_p, walk_subtrees, data); else if (TREE_CODE (stmt) == PTRMEM_CST) { diff --git a/gcc/testsuite/c-c++-common/goacc/pr85782.c b/gcc/testsuite/c-c++-common/goacc/pr85782.c new file mode 100644 index 0000000..f213a24 --- /dev/null +++ b/gcc/testsuite/c-c++-common/goacc/pr85782.c @@ -0,0 +1,11 @@ +/* PR c++/85782 */ + +void +foo () +{ + int i; + + #pragma acc parallel loop + for (i = 0; i < 100; i++) + continue; +} diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c new file mode 100644 index 0000000..6f84dfc --- /dev/null +++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/pr85782.c @@ -0,0 +1,32 @@ +/* PR c++/85782 */ + +#include <assert.h> + +#define N 100 + +int +main () +{ + int i, a[N]; + + for (i = 0; i < N; i++) + a[i] = i+1; + + #pragma acc parallel loop copy(a) + for (i = 0; i < N; i++) + { + if (i % 2) + continue; + a[i] = 0; + } + + for (i = 0; i < N; i++) + { + if (i % 2) + assert (a[i] == i+1); + else + assert (a[i] == 0); + } + + return 0; +}