Commit 7adb26f2 by Jakub Jelinek Committed by Jakub Jelinek

re PR c++/71257 (OpenMP declare simd linear with ref modifier doesn't accept…

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) <case OMP_CLAUSE_LINEAR>:
	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
parent e90434e3
2016-05-24 Jakub Jelinek <jakub@redhat.com>
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 <rguenther@suse.de> 2016-05-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/71240 PR tree-optimization/71240
......
2016-05-24 Jakub Jelinek <jakub@redhat.com>
PR c++/71257
* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_LINEAR>:
For OMP_CLAUSE_LINEAR_REF don't require type to be
integral or pointer.
2016-05-24 Richard Biener <rguenther@suse.de> 2016-05-24 Richard Biener <rguenther@suse.de>
PR middle-end/70434 PR middle-end/70434
......
...@@ -5881,7 +5881,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) ...@@ -5881,7 +5881,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
break; break;
} }
} }
else else if (OMP_CLAUSE_LINEAR_KIND (c) != OMP_CLAUSE_LINEAR_REF)
{ {
if (!INTEGRAL_TYPE_P (type) if (!INTEGRAL_TYPE_P (type)
&& TREE_CODE (type) != POINTER_TYPE) && TREE_CODE (type) != POINTER_TYPE)
......
2016-05-24 Jakub Jelinek <jakub@redhat.com> 2016-05-24 Jakub Jelinek <jakub@redhat.com>
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 middle-end/70434
PR c/69504 PR c/69504
* c-c++-common/vector-subscript-5.c (foo): Move ; out of the ifdef. * c-c++-common/vector-subscript-5.c (foo): Move ; out of the ifdef.
......
// 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);
// 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;
}
...@@ -3012,8 +3012,10 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, ...@@ -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); STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_push (bestn->decl);
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
if (bestn->simdclone->args[i].arg_type if ((bestn->simdclone->args[i].arg_type
== SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP) == 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 STMT_VINFO_SIMD_CLONE_INFO (stmt_info).safe_grow_cleared (i * 3
+ 1); + 1);
...@@ -3148,6 +3150,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, ...@@ -3148,6 +3150,7 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
vargs.safe_push (op); vargs.safe_push (op);
break; break;
case SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP:
case SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP:
if (j == 0) if (j == 0)
{ {
gimple_seq stmts; gimple_seq stmts;
...@@ -3211,6 +3214,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi, ...@@ -3211,6 +3214,8 @@ vectorizable_simd_clone_call (gimple *stmt, gimple_stmt_iterator *gsi,
vargs.safe_push (new_temp); vargs.safe_push (new_temp);
} }
break; 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_VARIABLE_STEP:
case SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_REF_VARIABLE_STEP:
case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP: case SIMD_CLONE_ARG_TYPE_LINEAR_VAL_VARIABLE_STEP:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment