class Hello { public static int foo() { return 1; } public static void x(int bar) { int [1d] local a = new int [1 : 10 : 2]; int [2d] local b = new int [2 : 5, 3 : 4]; int i = foo(); /* Working */ foreach (p in a.domain()) { a[p] = 3; } foreach (p in [1 : 5 : 2]) { a[p + [2]] = 3; } foreach (p in [5 : 9 : 2]) { a[p - [4]] = 3; } foreach (p in [2 : 2]) { a[p + [1]] = 3; } /* Broken */ if (bar == 0) foreach (p in [1 : 3]) { a[p + [1]] = 3; } if (bar == 1) foreach (p in [5 : 7 : 2]) { a[p + [i]] = 3; } if (bar == 2) foreach (p in [5 : 7 : 2]) { a[p + [1]] = 3; } if (bar == 3) foreach (p in [2 : 3]) { a[p + [1]] = 3; } } public static void y(int bar) { int [2d] local a = new int [2 : 52 : 4 , 3 : 9 : 3]; int [2d] local b = new int [10 : 22 : 2, 3 : 19 : 6]; int [2d] local c = b.restrict(a.domain()); int i = foo(); /* Working */ foreach (p in a.domain()) { a[p] = 3; } foreach (p in b.domain()) { b[p] = 3; } foreach (p in c.domain()) { b[p] = a[p]; c[p] = a[p]; } foreach (p in [1 : 5 : 2]) { a[p[1] * 2, p[1] / 10 + 3] = 3; } foreach (p in [5 : 39 : 4, 3 : 9 : 3]) { a[p + [1, 0]] = 3; } foreach (p in [3 : 39 : 4, 2 : 9 : 3]) { a[p + [-1, 1]] = 3; } foreach (p in [2 : 2, 2 : 2]) { a[p + [0, 1]] = 3; } foreach (p in [1 : 3, 5 : 10, 3 : 7]) a[4 * (p[1] + p[2] + p[3]) - 30, p[1] * 3] = i; foreach (p in [[10, 3] : [22, 9] : [4, 6]]) b[p] = 0; foreach (p in [[10, 3] : [22, 9] : [2, 6]]) b[p] = 0; /* Broken */ if (bar == 0) /* bogus due to restriction */ foreach (p in [[10, 3] : [22, 9] : [2, 6]]) c[p] = 0; if (bar == 1) /* all points off stride */ foreach (p in [[5, 3] : [5, 7] : [4, 3]]) a[p + [1, 1]] = 3; if (bar == 2) /* all points off stride */ foreach (p in [5 : 7 : 2]) a[2 * p[1] + i, 3] = 99; if (bar == 3) /* first ok, rest bogus */ foreach (p in [2 : 3, 9 : 13, 1 : 3]) a[p[1] + 4, p[3] + 5] = 33; } public static void main(String[] args) { try { if (args.length == 0) x(-1); else switch (Integer.parseInt(args[0])) { default: case 0: x(0); break; case 1: x(1); break; case 2: x(2); break; case 3: x(3); break; case 4: y(0); break; case 5: y(1); break; case 6: y(2); break; case 7: y(3); break; } } catch (Throwable x) {} System.out.println("Hello world!"); } }