libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-6.c
blob978cd4faa9bcefccaf2ab28091759b8f803c829b
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 #ifdef __aarch64__
12 #define TYPE1 int
13 #define TYPE2 int
14 #define TYPE3 short
15 #else
16 #define TYPE1 int
17 #define TYPE2 long long int
18 #define TYPE3 short
19 #endif
21 TYPE1 a[N];
22 TYPE2 b[N];
23 TYPE3 c[N];
25 #pragma omp declare simd
26 #pragma omp declare simd uniform(b) linear(c:3)
27 __attribute__((noinline)) TYPE3
28 foo (TYPE1 a, TYPE2 b, TYPE3 c)
30 return a + b + c;
33 __attribute__((noinline, noclone)) void
34 bar (int x)
36 int i;
37 if (x == 0)
39 #pragma omp simd
40 for (i = 0; i < N; i++)
41 c[i] = foo (a[i], b[i], c[i]);
43 else
45 #pragma omp simd
46 for (i = 0; i < N; i++)
47 c[i] = foo (a[i], x, i * 3);
51 __attribute__((noinline, noclone)) void
52 baz (void)
54 int i;
55 for (i = 0; i < N; i++)
57 a[i] = 2 * i;
58 b[i] = -7 * i + 6;
59 c[i] = (i & 31) << 4;
63 int
64 main ()
66 int i;
67 check_vect ();
68 baz ();
69 bar (0);
70 #pragma GCC novector
71 for (i = 0; i < N; i++)
72 if (a[i] != 2 * i || b[i] != 6 - 7 * i
73 || c[i] != 6 - 5 * i + ((i & 31) << 4))
74 abort ();
75 else
76 a[i] = c[i];
77 bar (17);
78 #pragma GCC novector
79 for (i = 0; i < N; i++)
80 if (a[i] != 6 - 5 * i + ((i & 31) << 4)
81 || b[i] != 6 - 7 * i
82 || c[i] != 23 - 2 * i + ((i & 31) << 4))
83 abort ();
84 return 0;