| 1 |
global a[10], b[10] |
| 2 |
|
| 3 |
// PR24811: Be sure to test non-constant iteration limit -- set to 0/1 in begin. |
| 4 |
global lim0 = 1 |
| 5 |
global lim1 = 0 |
| 6 |
|
| 7 |
probe begin { |
| 8 |
printf("BEGIN\n") |
| 9 |
|
| 10 |
a["p"] = -1 |
| 11 |
a["q"] = 0 |
| 12 |
a["r"] = 1 |
| 13 |
|
| 14 |
b[-1] = "p" |
| 15 |
b[0] = "q" |
| 16 |
b[1] = "r" |
| 17 |
|
| 18 |
lim0 = 0 |
| 19 |
lim1 = 1 |
| 20 |
exit() |
| 21 |
} |
| 22 |
|
| 23 |
global flag = 1 |
| 24 |
|
| 25 |
// XXX Split into separate probes due to stack size constraint. |
| 26 |
global end_probes = 0 // TODO: Remove this workaround for PR24812. |
| 27 |
|
| 28 |
probe end(1) { |
| 29 |
printf("first end probe\n") |
| 30 |
|
| 31 |
found = 0 |
| 32 |
foreach (ks+ in a limit lim1) { |
| 33 |
found++ |
| 34 |
if (a[ks] != -1) |
| 35 |
flag = 0 |
| 36 |
} |
| 37 |
|
| 38 |
foreach (k in b+ limit lim1) { |
| 39 |
found++ |
| 40 |
if (k != -1) |
| 41 |
flag = 0 |
| 42 |
} |
| 43 |
|
| 44 |
if (found != 2) |
| 45 |
flag = 0 |
| 46 |
|
| 47 |
if (end_probes < 3) |
| 48 |
end_probes++ // { end_probes++; next; } // TODO: Investigate using next here. |
| 49 |
else if (flag) |
| 50 |
printf("END PASS\n") |
| 51 |
else |
| 52 |
printf("END FAIL\n") |
| 53 |
} |
| 54 |
|
| 55 |
probe end(2) { |
| 56 |
printf("second end probe\n") |
| 57 |
|
| 58 |
foreach (ks- in a limit -10) |
| 59 |
flag = 0 |
| 60 |
|
| 61 |
foreach (ks- in a limit lim0) |
| 62 |
flag = 0 |
| 63 |
|
| 64 |
foreach (ks1 in a limit lim0) |
| 65 |
foreach (ks2 in a) |
| 66 |
flag = 0 |
| 67 |
|
| 68 |
foreach (ks1 in a) |
| 69 |
foreach (ks2 in a limit lim0) |
| 70 |
flag = 0 |
| 71 |
|
| 72 |
x = 0 |
| 73 |
foreach (ks in a) |
| 74 |
x += a[ks] |
| 75 |
flag = flag && x == 0 |
| 76 |
|
| 77 |
if (end_probes < 3) |
| 78 |
end_probes++ // { end_probes++; next; } // TODO: Investigate using next here. |
| 79 |
else if (flag) |
| 80 |
printf("END PASS\n") |
| 81 |
else |
| 82 |
printf("END FAIL\n") |
| 83 |
} |
| 84 |
|
| 85 |
probe end(3) { |
| 86 |
printf("third end probe\n") |
| 87 |
|
| 88 |
x = -1 |
| 89 |
foreach (ks+ in a) { |
| 90 |
flag = flag && x++ == a[ks] |
| 91 |
} |
| 92 |
flag = flag && x == 2 |
| 93 |
|
| 94 |
x = 1 |
| 95 |
foreach (ks- in a) { |
| 96 |
flag = flag && x-- == a[ks] |
| 97 |
} |
| 98 |
flag = flag && x == -2 |
| 99 |
|
| 100 |
x = -1 |
| 101 |
y = 1 |
| 102 |
foreach (ks1+ in a) { |
| 103 |
foreach (k2 in b-) { |
| 104 |
flag = flag && x == a[ks1] && y-- == k2 |
| 105 |
} |
| 106 |
x++ |
| 107 |
y = 1 |
| 108 |
} |
| 109 |
|
| 110 |
if (end_probes < 3) |
| 111 |
end_probes++ // { end_probes++; next; } // TODO: Investigate using next here. |
| 112 |
else if (flag) |
| 113 |
printf("END PASS\n") |
| 114 |
else |
| 115 |
printf("END FAIL\n") |
| 116 |
} |
| 117 |
|
| 118 |
probe end(4) { |
| 119 |
printf("fourth end probe\n") |
| 120 |
|
| 121 |
x = -1 |
| 122 |
y = 1 |
| 123 |
foreach (ks1+ in a) { |
| 124 |
foreach (ks2- in a) { |
| 125 |
flag = flag && x == a[ks1] && y-- == a[ks2] |
| 126 |
} |
| 127 |
x++ |
| 128 |
y = 1 |
| 129 |
} |
| 130 |
|
| 131 |
// Also test outer loop with no sorting, inner loop with sorting. |
| 132 |
x = -1 |
| 133 |
y = 1 |
| 134 |
foreach (ks1 in a) { |
| 135 |
foreach (ks2- in a) { |
| 136 |
flag = flag && y-- == a[ks2] |
| 137 |
} |
| 138 |
x++ |
| 139 |
y = 1 |
| 140 |
} |
| 141 |
|
| 142 |
if (end_probes < 3) |
| 143 |
end_probes++ // { end_probes++; next; } // TODO: Investigate using next here. |
| 144 |
else if (flag) |
| 145 |
printf("END PASS\n") |
| 146 |
else |
| 147 |
printf("END FAIL\n") |
| 148 |
} |