| 1 |
// { dg-require-effective-target vect_simd_clones } |
| 2 |
// { dg-additional-options "-fopenmp-simd -fno-inline" } |
| 3 |
// { dg-additional-options "-mavx" { target avx_runtime } } |
| 4 |
|
| 5 |
#include "../../gcc.dg/vect/tree-vect.h" |
| 6 |
|
| 7 |
struct S |
| 8 |
{ |
| 9 |
int s; |
| 10 |
#pragma omp declare simd notinbranch linear(x) |
| 11 |
int f (int x); |
| 12 |
}; |
| 13 |
|
| 14 |
#pragma omp declare simd notinbranch linear(x) |
| 15 |
int |
| 16 |
S::f (int x) |
| 17 |
{ |
| 18 |
return x; |
| 19 |
} |
| 20 |
|
| 21 |
template <int N> |
| 22 |
struct T |
| 23 |
{ |
| 24 |
int t; |
| 25 |
#pragma omp declare simd notinbranch linear(x) |
| 26 |
int f (int x); |
| 27 |
}; |
| 28 |
|
| 29 |
#pragma omp declare simd notinbranch linear(x) |
| 30 |
template <int N> |
| 31 |
int |
| 32 |
T<N>::f (int x) |
| 33 |
{ |
| 34 |
return x; |
| 35 |
} |
| 36 |
|
| 37 |
void |
| 38 |
do_main () |
| 39 |
{ |
| 40 |
int i, r = 0; |
| 41 |
S s; |
| 42 |
T<0> t; |
| 43 |
#pragma omp simd reduction(+:r) |
| 44 |
for (i = 0; i < 64; i++) |
| 45 |
r += s.f (i) + t.f (i); |
| 46 |
if (r != 64 * 63) |
| 47 |
abort (); |
| 48 |
} |
| 49 |
|
| 50 |
int |
| 51 |
main () |
| 52 |
{ |
| 53 |
check_vect (); |
| 54 |
do_main (); |
| 55 |
} |