This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/69363] ICE when doing a pragma simd reduction with max


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69363

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is that cp_parser_cilk_simd_all_clauses and
c_parser_cilk_simd_all_clauses calls c_finish_cilk_clauses rather than the
OpenMP clauses finalization routines in each of the FEs, perhaps with some
argument that would say it wants Cilk+ semantics instead of OpenMP.
That way, it misses lots of important actions that need to be performed on the
clauses.
E.g. for reduction performs in C++ finish_omp_reduction_clause, which looks up
the reduction, handles the placeholder, handles array reductions (not sure if
Cilk+ means to support them, if not, it should reject them during parsing), but
many other things (e.g. arrange for the ctors/copy ctors/assignment op/dtors to
be made available for the omp lowering purposes on privatization clauses where
needed, diagnosing invalid clause combinations (c_finish_cilk_clauses seems to
only reject the same var being in linear and some other clause, but the
gimplifier/middle-end will be certainly upset about many other duplications,
like
the same var both private and firstprivate, etc.).
So, I'd strongly recommend to just use the OpenMP clause finalization and if
you really need to tweak anything in there for Cilk+ compared to OpenMP rules,
test some cilk flag on those and add sufficient testsuite coverage for that.

As expected, with -fopenmp
#include <cmath>

double t1(double* x, int N) {
  double result = 0;
  int i;
#pragma omp simd reduction(max:result) private(i)
  for(int i=0; i<N; ++i) {
    result = std::fmax(x[i], result);
  }
  return result;
}
compiles fine.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]