Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-simd-clone-8.c

raw
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 #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 } */
23 {
24 return a + b + c;
25 }
26
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 } */
35 {
36 return a + b + c;
37 }
38
39 __attribute__((noinline)) void
40 fn1 (void)
41 {
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;
49 }
50
51 __attribute__((noinline)) void
52 fn2 (void)
53 {
54 int i;
55 #pragma omp simd
56 for (i = 0; i < N; i++)
57 {
58 a[i] = foo (c[i], a[i], b[i]) + 6;
59 d[i]++;
60 }
61 #pragma omp simd
62 for (i = 0; i < N; i++)
63 {
64 c[i] = bar (a[i], b[i], c[i]) * 2;
65 d[i] /= 2;
66 }
67 }
68
69 __attribute__((noinline)) void
70 fn3 (void)
71 {
72 int i;
73 for (i = 0; i < N; i++)
74 {
75 a[i] = i * 2;
76 b[i] = 17 + (i % 37);
77 c[i] = (i & 63);
78 d[i] = 16 + i;
79 }
80 }
81
82 int
83 main ()
84 {
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;
105 }