Merge from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-9.c
blob0c5ff4fa4382d908de762fe13f3dec48dd559226
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 #pragma omp declare simd notinbranch
16 __attribute__((noinline)) static int
17 foo (long int a, int b, int c)
19 return a + b + c;
22 #pragma omp declare simd notinbranch
23 __attribute__((noinline)) static long int
24 bar (int a, int b, long int c)
26 return a + b + c;
29 __attribute__((noinline)) void
30 fn1 (void)
32 int i;
33 #pragma omp simd
34 for (i = 0; i < N; i++)
35 a[i] = foo (c[i], a[i], b[i]) + 6;
36 #pragma omp simd
37 for (i = 0; i < N; i++)
38 c[i] = bar (a[i], b[i], c[i]) * 2;
41 __attribute__((noinline)) void
42 fn2 (void)
44 int i;
45 #pragma omp simd
46 for (i = 0; i < N; i++)
48 a[i] = foo (c[i], a[i], b[i]) + 6;
49 d[i]++;
51 #pragma omp simd
52 for (i = 0; i < N; i++)
54 c[i] = bar (a[i], b[i], c[i]) * 2;
55 d[i] /= 2;
59 __attribute__((noinline)) void
60 fn3 (void)
62 int i;
63 for (i = 0; i < N; i++)
65 a[i] = i * 2;
66 b[i] = 17 + (i % 37);
67 c[i] = (i & 63);
68 d[i] = 16 + i;
72 int
73 main ()
75 int i;
76 check_vect ();
77 fn3 ();
78 fn1 ();
79 for (i = 0; i < N; i++)
80 if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
81 || b[i] != 17 + (i % 37)
82 || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63))
83 abort ();
84 fn3 ();
85 fn2 ();
86 for (i = 0; i < N; i++)
87 if (a[i] != i * 2 + 23 + (i % 37) + (i & 63)
88 || b[i] != 17 + (i % 37)
89 || c[i] != i * 4 + 80 + 4 * (i % 37) + 4 * (i & 63)
90 || d[i] != ((unsigned char) (17 + i)) / 2)
91 abort ();
92 return 0;
95 /* { dg-final { cleanup-tree-dump "vect" } } */