1 | // RUN: %libomp-compile-and-run |
2 | // XFAIL: true |
3 | |
4 | // Non-rectangular loop collapsing. |
5 | // |
6 | // Nested loops conform to OpenMP 5.2 standard, |
7 | // inner loops bounds may depend on outer loops induction variables. |
8 | |
9 | #define LOOP_TYPES int |
10 | #define LOOP \ |
11 | for (i = iLB; i <= iUB; i += iStep) \ |
12 | for (j = i * jA1 + jA0; j <= i * jB1 + jB0; j += jStep) \ |
13 | for (k = j * kA1 + kA0; k <= j * kB1 + kB0; k += kStep) |
14 | #include "collapse_test.inc" |
15 | |
16 | int main() { |
17 | int fail = 0; |
18 | |
19 | iLB = -2; |
20 | iUB = 3; |
21 | jA0 = -7; |
22 | jA1 = -1; |
23 | jB0 = 13; |
24 | jB1 = 3; |
25 | kA0 = -20; |
26 | kA1 = -2; |
27 | kB0 = 111; |
28 | kB1 = -1; |
29 | iStep = 5; |
30 | jStep = 9; |
31 | kStep = 10; |
32 | PRINTF("\nOne off iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; jB1=%d; kA0=%d; " |
33 | "kA1=%d; kB0=%d; kB1=%d; iStep=%d; jStep=%d; kStep=%d;\n" , |
34 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, iStep, jStep, kStep); |
35 | fail = fail || (test() == 0); |
36 | |
37 | if (!fail) { |
38 | |
39 | // NOTE: if a loop on some level won't execute for all iterations of an |
40 | // outer loop, it still should work. Runtime doesn't require lower bounds to |
41 | // be <= upper bounds for all possible i, j, k. |
42 | |
43 | iLB = -2; |
44 | iUB = 3; |
45 | jA0 = -7; |
46 | jB0 = 5; |
47 | kA0 = -13; |
48 | kB0 = 37; |
49 | |
50 | for (kA1 = -2; kA1 <= 2; ++kA1) { // <= |
51 | for (kB1 = -2; kB1 <= 2; ++kB1) { |
52 | for (jA1 = -3; jA1 <= 3; ++jA1) { |
53 | for (jB1 = -3; jB1 <= 3; ++jB1) { |
54 | for (iStep = 1; iStep <= 3; ++iStep) { |
55 | for (jStep = 2; jStep <= 6; jStep += 2) { |
56 | for (kStep = 2; kStep <= 8; kStep += 3) { |
57 | PRINTF("\nTrying iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; " |
58 | "jB1=%d; kA0=%d; kA1=%d; kB0=%d; kB1=%d; iStep=%d; " |
59 | "jStep=%d; kStep=%d;\n" , |
60 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, |
61 | iStep, jStep, kStep); |
62 | fail = fail || (test() == 0); |
63 | } |
64 | } |
65 | } |
66 | } |
67 | } |
68 | } |
69 | } |
70 | } |
71 | |
72 | return fail; |
73 | } |
74 | |