libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-1.c
blob6bd4af36710984c3496e4a611c1590b8d423a74e
1 /* { dg-require-effective-target vect_simd_clones } */
2 /* { dg-additional-options "-fopenmp-simd" } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 #include "tree-vect.h"
7 #ifndef N
8 #define N 1024
9 #endif
11 int array[N];
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 } */
27 if (a < 30)
28 return 5;
29 return a + b + c;
32 __attribute__((noinline, noclone)) void
33 bar ()
35 int i;
36 #pragma omp simd
37 for (i = 0; i < N; ++i)
38 array[i] = foo (i, 123, i * 3);
41 __attribute__((noinline, noclone)) void
42 baz ()
44 int i;
45 #pragma omp simd
46 for (i = 0; i < N; ++i)
47 array[i] = foo (i, array[i], i * 3);
50 int
51 main ()
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;