libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-8.c
blob8d7448f7cb3934fd1ed09b3fe86ffcaadac1f34f
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 a[N], b[N];
12 long int c[N];
13 unsigned char d[N];
15 #ifdef __aarch64__
16 #pragma omp declare simd simdlen(2) notinbranch
17 #else
18 #pragma omp declare simd simdlen(8) notinbranch
19 #endif
20 __attribute__((noinline)) int
21 foo (long int a, int b, int c)
22 /* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */
24 return a + b + c;
27 #ifdef __aarch64__
28 #pragma omp declare simd simdlen(2) notinbranch
29 #else
30 #pragma omp declare simd simdlen(8) notinbranch
31 #endif
32 __attribute__((noinline)) long int
33 bar (int a, int b, long int c)
34 /* { dg-warning {unsupported simdlen 8 \(amdgcn\)} "" { target amdgcn*-*-* } .-1 } */
36 return a + b + c;
39 __attribute__((noinline)) void
40 fn1 (void)
42 int i;
43 #pragma omp simd
44 for (i = 0; i < N; i++)
45 a[i] = foo (c[i], a[i], b[i]) + 6;
46 #pragma omp simd
47 for (i = 0; i < N; i++)
48 c[i] = bar (a[i], b[i], c[i]) * 2;
51 __attribute__((noinline)) void
52 fn2 (void)
54 int i;
55 #pragma omp simd
56 for (i = 0; i < N; i++)
58 a[i] = foo (c[i], a[i], b[i]) + 6;
59 d[i]++;
61 #pragma omp simd
62 for (i = 0; i < N; i++)
64 c[i] = bar (a[i], b[i], c[i]) * 2;
65 d[i] /= 2;
69 __attribute__((noinline)) void
70 fn3 (void)
72 int i;
73 for (i = 0; i < N; i++)
75 a[i] = i * 2;
76 b[i] = 17 + (i % 37);
77 c[i] = (i & 63);
78 d[i] = 16 + i;
82 int
83 main ()
85 int i;
86 check_vect ();
87 fn3 ();
88 fn1 ();
89 #pragma GCC novector
90 for (i = 0; i < N; i++)
91 if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
92 || b[i] != 17 + (i % 37)
93 || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63))
94 abort ();
95 fn3 ();
96 fn2 ();
97 #pragma GCC novector
98 for (i = 0; i < N; i++)
99 if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
100 || b[i] != 17 + (i % 37)
101 || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)
102 || d[i] != ((unsigned char) (17 + i)) / 2)
103 abort ();
104 return 0;