From: Jakub Jelinek Date: Sat, 20 Jul 2019 06:38:59 +0000 (+0200) Subject: omp-low.c (lower_rec_input_clauses): Don't force simd arrays for lastprivate non... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b6339213ff68ac5a87b7fdda878f26b52d801b76;p=gcc.git omp-low.c (lower_rec_input_clauses): Don't force simd arrays for lastprivate non-addressable iterator of a... * omp-low.c (lower_rec_input_clauses): Don't force simd arrays for lastprivate non-addressable iterator of a collapse(1) simd. * gcc.dg/vect/vect-simd-16.c: New test. From-SVN: r273620 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 92e5b2e36a1..40f6db590b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-07-20 Jakub Jelinek + + * omp-low.c (lower_rec_input_clauses): Don't force simd arrays for + lastprivate non-addressable iterator of a collapse(1) simd. + 2019-07-17 Bill Seurer * config/rs6000/rs6000-call.c (HAVE_AS_GNU_ATTRIBUTE): define value diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a18f24c7f96..03df07b63f1 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -5097,7 +5097,10 @@ lower_rec_input_clauses (tree clauses, gimple_seq *ilist, gimple_seq *dlist, { tree y = lang_hooks.decls.omp_clause_dtor (c, new_var); if ((TREE_ADDRESSABLE (new_var) || nx || y - || OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE + || (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_LASTPRIVATE + && (gimple_omp_for_collapse (ctx->stmt) != 1 + || (gimple_omp_for_index (ctx->stmt, 0) + != new_var))) || OMP_CLAUSE_CODE (c) == OMP_CLAUSE__CONDTEMP_ || omp_is_reference (var)) && lower_rec_simd_input_clauses (new_var, ctx, &sctx, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ce8e3c781b9..a7c94269075 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-20 Jakub Jelinek + + * gcc.dg/vect/vect-simd-16.c: New test. + 2019-07-19 Jeff Law * gcc.dg/tree-ssa/ssa-dse-37.c: New test. diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-16.c b/gcc/testsuite/gcc.dg/vect/vect-simd-16.c new file mode 100644 index 00000000000..ee4459a9341 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-16.c @@ -0,0 +1,61 @@ +/* { dg-additional-options "-fopenmp-simd" } */ +/* { dg-additional-options "-mavx" { target avx_runtime } } */ +/* { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 3 "vect" { target i?86-*-* x86_64-*-* } } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) int +foo (int *a) +{ + int i; + #pragma omp simd lastprivate (i) + for (i = 0; i < 64; i++) + a[i] = i; + return i; +} + +__attribute__((noipa)) void +bar (int *a) +{ + int i; + #pragma omp simd private (i) + for (i = 0; i < 64; i++) + a[i] = i + 1; +} + +__attribute__((noipa)) int +baz (int *a) +{ + int i; + #pragma omp simd linear (i) + for (i = 0; i < 64; i++) + a[i] = i + 2; + return i; +} + +int +main () +{ + int i; + int a[64]; + check_vect (); + if (foo (a) != 64) + abort (); + for (i = 0; i < 64; ++i) + if (a[i] != i) + abort (); + else + a[i] = -8; + bar (a); + for (i = 0; i < 64; ++i) + if (a[i] != i + 1) + abort (); + else + a[i] = -8; + if (baz (a) != 64) + abort (); + for (i = 0; i < 64; ++i) + if (a[i] != i + 2) + abort (); + return 0; +}