On Fri, Jun 04, 2021 at 07:47:50PM +0200, Tobias Burnus wrote: > Fails due to the (explicit or implicitly added) 'bind' clause as > tree-nested.c did not handle them. > > In convert_nonlocal_omp_clauses, the following clauses are > missing: OMP_CLAUSE_AFFINITY, OMP_CLAUSE_DEVICE_TYPE, > OMP_CLAUSE_EXCLUSIVE, OMP_CLAUSE_INCLUSIVE. > > I am not sure which of them should or must be added – but the > 'bind' clause for sure; I did add 'affinity' but it is currently > removed during gimplification – hence, I think leaving it out > would also be an option. > > Lightly tested. OK once/when testing has succeeded?
Because OMP_CLAUSE_AFFINITY is dropped during gimplification, I'd leave OMP_CLAUSE_AFFINITY out. Ok for trunk with that change. And OMP_CLAUSE_{EXCLUSIVE,INCLUSIVE} isn't needed, because we don't walk the clauses at all for GIMPLE_OMP_SCAN. It would be a bug if we used the exclusive/inclusive operands after gimplification, but we apparently don't do that, all we check is whether the OMP_CLAUSE_KIND of the first clause (all should be the same) is OMP_CLAUSE_EXCLUSIVE or OMP_CLAUSE_INCLUSIVE, nothing else. That said, I think we should have a testcase, so I'll commit following after testing: 2021-06-04 Jakub Jelinek <ja...@redhat.com> * gcc.dg/gomp/scan-1.c: New test. --- gcc/testsuite/gcc.dg/gomp/scan-1.c.jj 2021-06-04 20:03:44.250674711 +0200 +++ gcc/testsuite/gcc.dg/gomp/scan-1.c 2021-06-04 20:03:31.164851821 +0200 @@ -0,0 +1,51 @@ +int baz (void); +void qux (int); +int r; + +int +foo (void) +{ + int r = 0, i; + void bar (void) { r++; } + #pragma omp parallel for reduction(inscan, +:r) + for (i = 0; i < 64; i++) + { + r += baz (); + #pragma omp scan inclusive(r) + qux (r); + } + #pragma omp parallel for reduction(inscan, +:r) + for (i = 0; i < 64; i++) + { + qux (r); + #pragma omp scan exclusive(r) + r += baz (); + } + bar (); + return r; +} + +int +corge (void) +{ + int r = 0, i; + void bar (void) + { + #pragma omp parallel for reduction(inscan, +:r) + for (i = 0; i < 64; i++) + { + r += baz (); + #pragma omp scan inclusive(r) + qux (r); + } + #pragma omp parallel for reduction(inscan, +:r) + for (i = 0; i < 64; i++) + { + qux (r); + #pragma omp scan exclusive(r) + r += baz (); + } + } + bar (); + return r; +} Jakub