1 | // RUN: %libomp-compile-and-run |
2 | |
3 | // Non-rectangular loop collapsing. |
4 | // |
5 | // Nested loops conform to OpenMP 5.2 standard, |
6 | // inner loops bounds may depend on outer loops induction variables. |
7 | |
8 | #define LOOP_TYPES int |
9 | #define COMPARE0 < |
10 | #define COMPARE1 <= |
11 | #define COMPARE2 >= |
12 | #define LOOP \ |
13 | for (i = iLB; i COMPARE0 iUB; i += iStep) \ |
14 | for (j = jA0; j COMPARE1 jB0; j += jStep) \ |
15 | for (k = kA0; k COMPARE2 kB0; k += kStep) |
16 | #include "collapse_test.inc" |
17 | |
18 | int main() { |
19 | int fail; |
20 | |
21 | iLB = -2; |
22 | iUB = 3; |
23 | jA0 = -3; |
24 | jA1 = 0; |
25 | jB0 = -6; |
26 | jB1 = 0; |
27 | kA0 = -2; |
28 | kA1 = 0; |
29 | kB0 = -4; |
30 | kB1 = 0; |
31 | iStep = -1; |
32 | jStep = -1; |
33 | kStep = -4; |
34 | PRINTF("\nOne off iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; jB1=%d; kA0=%d; " |
35 | "kA1=%d; kB0=%d; kB1=%d; iStep=%d; jStep=%d; kStep=%d;\n" , |
36 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, iStep, jStep, kStep); |
37 | fail = (test() == 0); |
38 | |
39 | if (!fail) { |
40 | |
41 | for (iStep = 2; iStep <= 6; iStep += 2) { |
42 | for (jA0 = -6; jA0 <= 6; jA0 += 3) { |
43 | for (jB0 = -3; jB0 <= 10; jB0 += 3) { |
44 | for (jStep = 1; jStep <= 10; jStep += 2) { |
45 | for (kA0 = -2; kA0 <= 4; ++kA0) { |
46 | for (kB0 = -4; kB0 <= 2; ++kB0) { |
47 | for (kStep = -2; kStep >= -10; kStep -= 4) { |
48 | { |
49 | PRINTF("\nTrying iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; " |
50 | "jB1=%d; kA0=%d; kA1=%d; kB0=%d; kB1=%d; iStep=%d; " |
51 | "jStep=%d; kStep=%d;\n" , |
52 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, |
53 | iStep, jStep, kStep); |
54 | fail = fail || (test() == 0); |
55 | } |
56 | } |
57 | } |
58 | } |
59 | } |
60 | } |
61 | } |
62 | } |
63 | } |
64 | |
65 | return fail; |
66 | } |
67 | |