From: Jakub Jelinek Date: Tue, 24 May 2016 16:19:43 +0000 (+0200) Subject: re PR c++/71257 (OpenMP declare simd linear with ref modifier doesn't accept referenc... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7adb26f20259aadcd6e2df6ece474eca615af978;p=gcc.git re PR c++/71257 (OpenMP declare simd linear with ref modifier doesn't accept references to non-integer/non-pointer) PR c++/71257 * tree-vect-stmts.c (vectorizable_simd_clone_call): Handle SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP. Add SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP and SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP cases explicitly. * semantics.c (finish_omp_clauses) : For OMP_CLAUSE_LINEAR_REF don't require type to be integral or pointer. * g++.dg/vect/simd-clone-6.cc: New test. * g++.dg/gomp/declare-simd-6.C: New test. From-SVN: r236648 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ca7e794ef7..1b81d4106f8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-05-24 Jakub Jelinek + + PR c++/71257 + * tree-vect-stmts.c (vectorizable_simd_clone_call): Handle + SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like + SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP. Add + SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP and + SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP cases explicitly. + 2016-05-24 Richard Biener PR tree-optimization/71240 diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index eaf42b83f1c..c77dee6dfb7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2016-05-24 Jakub Jelinek + + PR c++/71257 + * semantics.c (finish_omp_clauses) : + For OMP_CLAUSE_LINEAR_REF don't require type to be + integral or pointer. + 2016-05-24 Richard Biener PR middle-end/70434 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 06dee5a6669..21ef42f5534 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5881,7 +5881,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) break; } } - else + else if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF) { if (!INTEGRAL_TYPE_P (type) && TREE_CODE (type) != POINTER_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2f66ad1d8e8..c0a271cefd9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2016-05-24 Jakub Jelinek + PR c++/71257 + * g++.dg/vect/simd-clone-6.cc: New test. + * g++.dg/gomp/declare-simd-6.C: New test. + PR middle-end/70434 PR c/69504 * c-c++-common/vector-subscript-5.c (foo): Move ; out of the ifdef. diff --git a/gcc/testsuite/g++.dg/gomp/declare-simd-6.C b/gcc/testsuite/g++.dg/gomp/declare-simd-6.C new file mode 100644 index 00000000000..09137ee5b98 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/declare-simd-6.C @@ -0,0 +1,37 @@ +// PR c++/71257 +// { dg-do compile } +// { dg-options "-fopenmp-simd" } + +struct S { int a; }; +#pragma omp declare simd linear(val(a):2) +int f1 (int &a); +#pragma omp declare simd linear(uval(a):2) +unsigned short f2 (unsigned short &a); +#pragma omp declare simd linear(ref(a):1) +int f3 (long long int &a); +#pragma omp declare simd linear(a:1) +int f4 (int &a); +#pragma omp declare simd linear(val(a)) +int f5 (int a); +#pragma omp declare simd linear(uval(a):2) // { dg-error "modifier applied to non-reference variable" } +int f6 (unsigned short a); +#pragma omp declare simd linear(ref(a):1) // { dg-error "modifier applied to non-reference variable" } +int f7 (unsigned long int a); +#pragma omp declare simd linear(a:1) +int f8 (int a); +#pragma omp declare simd linear(val(a):2) // { dg-error "applied to non-integral non-pointer variable" } +int f9 (S &a); +#pragma omp declare simd linear(uval(a):2) // { dg-error "applied to non-integral non-pointer variable" } +int f10 (S &a); +#pragma omp declare simd linear(ref(a):1) // { dg-bogus "applied to non-integral non-pointer variable" } +int f11 (S &a); +#pragma omp declare simd linear(a:1) // { dg-error "applied to non-integral non-pointer variable" } +int f12 (S &a); +#pragma omp declare simd linear(val(a)) // { dg-error "applied to non-integral non-pointer variable" } +int f13 (S a); +#pragma omp declare simd linear(uval(a):2) // { dg-error "modifier applied to non-reference variable" } +int f14 (S a); +#pragma omp declare simd linear(ref(a):1) // { dg-error "modifier applied to non-reference variable" } +int f15 (S a); +#pragma omp declare simd linear(a:1) // { dg-error "applied to non-integral non-pointer variable" } +int f16 (S a); diff --git a/gcc/testsuite/g++.dg/vect/simd-clone-6.cc b/gcc/testsuite/g++.dg/vect/simd-clone-6.cc new file mode 100644 index 00000000000..fb00e8816a5 --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/simd-clone-6.cc @@ -0,0 +1,43 @@ +// PR c++/71257 +// { dg-require-effective-target vect_simd_clones } +// { dg-additional-options "-fopenmp-simd -fno-inline" } +// { dg-additional-options "-mavx" { target avx_runtime } } + +#include "../../gcc.dg/vect/tree-vect.h" + +#define N 1024 +struct S { int a; }; +int c[N], e[N], f[N]; +S d[N]; + +#pragma omp declare simd linear(ref(b, c) : 1) +int +foo (int a, S &b, int &c) +{ + return a + b.a + c; +} + +void +do_main () +{ + int i; + for (i = 0; i < N; i++) + { + c[i] = i; + d[i].a = 2 * i; + f[i] = 3 * i; + } + #pragma omp simd + for (i = 0; i < N; i++) + e[i] = foo (c[i], d[i], f[i]); + for (i = 0; i < N; i++) + if (e[i] != 6 * i) + __builtin_abort (); +} + +int +main () +{ + check_vect (); + return 0; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index d9e9cbbba5c..f11f22e3eb8 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -3012,8 +3012,10 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, { STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (bestn->decl); for (i = 0; i < nargs; i++) - if (bestn->simdclone->args[i].arg_type - == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP) + if ((bestn->simdclone->args[i].arg_type + == SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP) + || (bestn->simdclone->args[i].arg_type + == SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP)) { STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_grow_cleared (i * 3 + 1); @@ -3148,6 +3150,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, vargs.safe_push (op); break; case SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP: + case SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP: if (j == 0) { gimple_seq stmts; @@ -3211,6 +3214,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, vargs.safe_push (new_temp); } break; + case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP: + case SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP: