Merge from trunk
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-simd-clone-1.c
blob9fdd056388997ee08fb372cb9cf929c093dc848c
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 #pragma omp declare simd simdlen(8) notinbranch
16 #pragma omp declare simd simdlen(8) notinbranch uniform(b) linear(c:3)
17 __attribute__((noinline)) int
18 foo (int a, int b, int c)
20 if (a < 30)
21 return 5;
22 return a + b + c;
25 __attribute__((noinline, noclone)) void
26 bar ()
28 int i;
29 #pragma omp simd
30 for (i = 0; i < N; ++i)
31 array[i] = foo (i, 123, i * 3);
34 __attribute__((noinline, noclone)) void
35 baz ()
37 int i;
38 #pragma omp simd
39 for (i = 0; i < N; ++i)
40 array[i] = foo (i, array[i], i * 3);
43 int
44 main ()
46 int i;
47 check_vect ();
48 bar ();
49 for (i = 0; i < N; i++)
50 if (array[i] != (i < 30 ? 5 : i * 4 + 123))
51 abort ();
52 baz ();
53 for (i = 0; i < N; i++)
54 if (array[i] != (i < 30 ? 5 : i * 8 + 123))
55 abort ();
56 return 0;
59 /* { dg-final { cleanup-tree-dump "vect" } } */