https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111403
Bug ID: 111403 Summary: LoongArch: Wrong code with -O -mlasx -fopenmp-simd Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: xry111 at gcc dot gnu.org Target Milestone: --- Testcase: struct S { int s; S () : s (0) {} ~S () {} S (const S &x) { s = x.s; } S & operator= (const S &x) { s = x.s; return *this; } }; S r, a[1024], b[1024]; #pragma omp declare reduction(+ : S : omp_out.s += omp_in.s) __attribute__ ((noipa)) void foo (S *a, S *b) { #pragma omp simd reduction(inscan, + : r) for (int i = 0; i < 1024; i++) { r.s += a[i].s; #pragma omp scan inclusive(r) b[i] = r; } } int main () { S s; for (int i = 0; i < 1024; ++i) { a[i].s = i; b[i].s = -1; } foo (a, b); if (r.s != 1024 * 1023 / 2) __builtin_abort (); return 0; } $ g++ t.cc -O -mlasx -fopenmp-simd $ ./a.out Aborted (core dumped)