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 | |
13 | #define DLOOP_GT0 |
14 | #define DLOOP_GE1 |
15 | #define DLOOP_GT2 |
16 | |
17 | #define LOOP \ |
18 | for (i = iLB; i COMPARE0 iUB; i += iStep) \ |
19 | for (j = jA0; j COMPARE1 jB0; j += jStep) \ |
20 | for (k = kA0; k COMPARE2 kB0; k += kStep) |
21 | #include "collapse_test.inc" |
22 | |
23 | int main() { |
24 | int fail; |
25 | |
26 | iLB = 3; |
27 | iUB = -2; |
28 | jA0 = -3; |
29 | jA1 = 0; |
30 | jB0 = -6; |
31 | jB1 = 0; |
32 | kA0 = -2; |
33 | kA1 = 0; |
34 | kB0 = -4; |
35 | kB1 = 0; |
36 | iStep = -1; |
37 | jStep = -1; |
38 | kStep = -4; |
39 | PRINTF("\nOne off iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; jB1=%d; kA0=%d; " |
40 | "kA1=%d; kB0=%d; kB1=%d; iStep=%d; jStep=%d; kStep=%d;\n" , |
41 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, iStep, jStep, kStep); |
42 | fail = (test() == 0); |
43 | |
44 | if (!fail) { |
45 | |
46 | for (iStep = -3; iStep >= -6; iStep -= 2) { |
47 | for (jA0 = -3; jA0 <= 10; jA0 += 3) { |
48 | for (jB0 = -6; jB0 <= 6; jB0 += 3) { |
49 | for (jStep = -1; jStep >= -10; jStep -= 2) { |
50 | for (kA0 = -2; kA0 <= 4; ++kA0) { |
51 | for (kB0 = -4; kB0 <= 2; ++kB0) { |
52 | for (kStep = -2; kStep >= -10; kStep -= 4) { |
53 | { |
54 | PRINTF("\nTrying iLB=%d; iUB=%d; jA0=%d; jA1=%d; jB0=%d; " |
55 | "jB1=%d; kA0=%d; kA1=%d; kB0=%d; kB1=%d; iStep=%d; " |
56 | "jStep=%d; kStep=%d;\n" , |
57 | iLB, iUB, jA0, jA1, jB0, jB1, kA0, kA1, kB0, kB1, |
58 | iStep, jStep, kStep); |
59 | fail = fail || (test() == 0); |
60 | } |
61 | } |
62 | } |
63 | } |
64 | } |
65 | } |
66 | } |
67 | } |
68 | } |
69 | |
70 | return fail; |
71 | } |
72 | |