| 1 |
/* { dg-require-effective-target vect_simd_clones } */ |
| 2 |
/* { dg-additional-options "-fopenmp-simd" } */ |
| 3 |
/* { dg-additional-options "-mavx" { target avx_runtime } } */ |
| 4 |
|
| 5 |
#include "tree-vect.h" |
| 6 |
|
| 7 |
#ifndef N |
| 8 |
#define N 1024 |
| 9 |
#endif |
| 10 |
|
| 11 |
int array[N]; |
| 12 |
|
| 13 |
#pragma omp declare simd simdlen(4) notinbranch |
| 14 |
#pragma omp declare simd simdlen(4) notinbranch uniform(b) linear(c:3) |
| 15 |
#ifdef __aarch64__ |
| 16 |
#pragma omp declare simd simdlen(2) notinbranch |
| 17 |
#pragma omp declare simd simdlen(2) notinbranch uniform(b) linear(c:3) |
| 18 |
#else |
| 19 |
#pragma omp declare simd simdlen(8) notinbranch |
| 20 |
#pragma omp declare simd simdlen(8) notinbranch uniform(b) linear(c:3) |
| 21 |
#endif |
| 22 |
__attribute__((noinline)) int |
| 23 |
foo (int a, int b, int c) |
| 24 |
/* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */ |
| 25 |
/* { dg-warning {unsupported simdlen 4 \(amdgcn\)} "" { target amdgcn*-*-* } .-2 } */ |
| 26 |
{ |
| 27 |
if (a < 30) |
| 28 |
return 5; |
| 29 |
return a + b + c; |
| 30 |
} |
| 31 |
|
| 32 |
__attribute__((noinline, noclone)) void |
| 33 |
bar () |
| 34 |
{ |
| 35 |
int i; |
| 36 |
#pragma omp simd |
| 37 |
for (i = 0; i < N; ++i) |
| 38 |
array[i] = foo (i, 123, i * 3); |
| 39 |
} |
| 40 |
|
| 41 |
__attribute__((noinline, noclone)) void |
| 42 |
baz () |
| 43 |
{ |
| 44 |
int i; |
| 45 |
#pragma omp simd |
| 46 |
for (i = 0; i < N; ++i) |
| 47 |
array[i] = foo (i, array[i], i * 3); |
| 48 |
} |
| 49 |
|
| 50 |
int |
| 51 |
main () |
| 52 |
{ |
| 53 |
int i; |
| 54 |
check_vect (); |
| 55 |
bar (); |
| 56 |
#pragma GCC novector |
| 57 |
for (i = 0; i < N; i++) |
| 58 |
if (array[i] != (i < 30 ? 5 : i * 4 + 123)) |
| 59 |
abort (); |
| 60 |
baz (); |
| 61 |
#pragma GCC novector |
| 62 |
for (i = 0; i < N; i++) |
| 63 |
if (array[i] != (i < 30 ? 5 : i * 8 + 123)) |
| 64 |
abort (); |
| 65 |
return 0; |
| 66 |
} |