1 /* { dg-require-effective-target vect_simd_clones } */
2 /* { dg-additional-options "-fopenmp-simd" } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
4
5 #include "tree-vect.h"
6
7 #ifndef N
8 #define N 1024
9 #endif
10
11 int a[N], b[N];
12 long int c[N];
13 unsigned char d[N];
14
15 #pragma omp declare simd simdlen(8) notinbranch
16 __attribute__((noinline)) int
foo(long int a,int b,int c)17 foo (long int a, int b, int c)
18 {
19 return a + b + c;
20 }
21
22 #pragma omp declare simd simdlen(8) notinbranch
23 __attribute__((noinline)) long int
bar(int a,int b,long int c)24 bar (int a, int b, long int c)
25 {
26 return a + b + c;
27 }
28
29 __attribute__((noinline)) void
fn1(void)30 fn1 (void)
31 {
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;
39 }
40
41 __attribute__((noinline)) void
fn2(void)42 fn2 (void)
43 {
44 int i;
45 #pragma omp simd
46 for (i = 0; i < N; i++)
47 {
48 a[i] = foo (c[i], a[i], b[i]) + 6;
49 d[i]++;
50 }
51 #pragma omp simd
52 for (i = 0; i < N; i++)
53 {
54 c[i] = bar (a[i], b[i], c[i]) * 2;
55 d[i] /= 2;
56 }
57 }
58
59 __attribute__((noinline)) void
fn3(void)60 fn3 (void)
61 {
62 int i;
63 for (i = 0; i < N; i++)
64 {
65 a[i] = i * 2;
66 b[i] = 17 + (i % 37);
67 c[i] = (i & 63);
68 d[i] = 16 + i;
69 }
70 }
71
72 int
main()73 main ()
74 {
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;
93 }
94
95