Daily bump.
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr58756.c
blob34877accd3a5639afcfbc9695d15e04372c7804c
1 /* PR libgomp/58756 */
2 /* { dg-do run } */
3 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
4 /* { dg-additional-options "-mavx" { target avx_runtime } } */
6 extern void abort (void);
7 int d[32 * 32];
9 __attribute__((noinline, noclone)) int
10 foo (int a, int b)
12 int j, c = 0;
13 #pragma omp parallel for reduction(+: c)
14 for (j = 0; j < a; j += 32)
16 int l;
17 #pragma omp simd reduction(+: c) safelen(1)
18 for (l = 0; l < b; ++l)
19 c += d[j + l];
21 return c;
24 __attribute__((noinline, noclone)) int
25 bar (int a)
27 int j, c = 0;
28 #pragma omp parallel for simd reduction(+: c) safelen(1)
29 for (j = 0; j < a; ++j)
30 c += d[j];
31 return c;
34 __attribute__((noinline)) static int
35 baz (int a)
37 int j, c = 0;
38 #pragma omp simd reduction(+: c) safelen(1)
39 for (j = 0; j < a; ++j)
40 c += d[j];
41 return c;
44 int
45 main ()
47 int i;
48 for (i = 0; i < 32 * 32; i++)
49 d[i] = (i & 31);
50 if (foo (32 * 32, 32) != (31 * 32 / 2) * 32)
51 abort ();
52 if (bar (32 * 32) != (31 * 32 / 2) * 32)
53 abort ();
54 if (baz (32 * 32) != (31 * 32 / 2) * 32)
55 abort ();
56 return 0;