PR target/77349
[official-gcc.git] / libgomp / testsuite / libgomp.c / taskloop-3.c
blob5356d7f0251cc45a73964c503f1d0b68eff37390
1 /* { dg-do run } */
2 /* { dg-options "-O2 -fopenmp -std=c99" } */
4 int g;
5 int a[1024];
7 __attribute__((noinline, noclone)) int
8 f1 (int x)
10 #pragma omp taskloop firstprivate (x) lastprivate (x)
11 for (int i = 0; i < 64; i++)
13 if (x != 74)
14 __builtin_abort ();
15 if (i == 63)
16 x = i + 4;
18 return x;
21 __attribute__((noinline, noclone)) void
22 f2 (void)
24 #pragma omp taskloop firstprivate (g) lastprivate (g) nogroup
25 for (int i = 0; i < 64; i++)
27 if (g != 77)
28 __builtin_abort ();
29 if (i == 63)
30 g = i + 9;
34 __attribute__((noinline, noclone)) long long
35 f3 (long long a, long long b, long long c)
37 long long i;
38 int l;
39 #pragma omp taskloop default (none) lastprivate (i, l)
40 for (i = a; i < b; i += c)
41 l = i;
42 return l * 7 + i;
45 __attribute__((noinline, noclone)) long long
46 f4 (long long a, long long b, long long c, long long d,
47 long long e, long long f, int k)
49 long long i, j;
50 int l;
51 #pragma omp taskloop default (none) collapse(2) \
52 firstprivate (k) lastprivate (i, j, k, l)
53 for (i = a; i < b; i += e)
54 for (j = c; j < d; j += f)
56 if (k != 73)
57 __builtin_abort ();
58 if (i == 31 && j == 46)
59 k = i;
60 l = j;
62 return i + 5 * j + 11 * k + 17 * l;
65 int
66 main ()
68 #pragma omp parallel
69 #pragma omp single
71 if (f1 (74) != 63 + 4)
72 __builtin_abort ();
73 g = 77;
74 f2 ();
75 #pragma omp taskwait
76 if (g != 63 + 9)
77 __builtin_abort ();
78 if (f3 (7, 12, 2) != 11 * 7 + 13)
79 __builtin_abort ();
80 if (f4 (0, 32, 16, 48, 1, 2, 73) != 32 + 5 * 48 + 11 * 31 + 17 * 46)
81 __builtin_abort ();
83 return 0;