diff options
Diffstat (limited to 'tests/programs/o3licm.zc')
| -rw-r--r-- | tests/programs/o3licm.zc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/programs/o3licm.zc b/tests/programs/o3licm.zc new file mode 100644 index 0000000..61e6a46 --- /dev/null +++ b/tests/programs/o3licm.zc @@ -0,0 +1,46 @@ +// loop invariants are built once in front of the loop, and a value two blocks both build is shared. +// every result below has to match the plain run (ZYNOSHARE=1 turns the pass off). +unchecked o3 int nest(int n, int k) { + int s = 0; + for (int i = 0; i < n; i++) { + for (int j = 0; j < n; j++) { + s = s + (k * 37 + 11) * (i + j); + } + } + return s; +} +unchecked o3 int loads(int* a, int n) { + int s = 0; + for (int i = 0; i < n; i++) s = s + a[0] * a[1] + i; + return s; +} +unchecked o3 int stores(int* a, int n) { + int s = 0; + for (int i = 0; i < n; i++) { a[0] = a[0] + 1; s = s + a[0] * 3; } + return s; +} +unchecked o3 int branchy(int x, int y, int n) { + int s = 0; + for (int i = 0; i < n; i++) { + if (i & 1) s = s + x * y * 5; + else s = s - x * y * 5 + i; + } + return s; +} +unchecked o3 int twice(int x, int y) { + int r = 0; + if (x > 0) r = (x * y + 3) * (x * y + 3); + else r = x * y + 3; + return r + (x * y + 3) * 7; +} +unchecked fn main() { + int* a = new(int, 4); + a[0] = 5; a[1] = 6; + put_n(nest(30, 3)); put_c(' '); + put_n(loads(a, 100)); put_c(' '); + put_n(stores(a, 10)); put_c(' '); + put_n(branchy(3, 4, 21)); put_c(' '); + put_n(twice(5, 2)); put_c(' '); + put_n(twice(-5, 2)); put_c(10); + return 0; +} |
