PR rtl-optimization/77919
[official-gcc.git] / libgomp / testsuite / libgomp.c / pr58392.c
blob21ad2bf0bdb1c8b73a7a9b53d21b2ee728bf8fff
1 /* PR tree-optimization/58392 */
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)
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)
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)
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;