aboutsummaryrefslogtreecommitdiff
path: root/tests/programs/o3copy.zc
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/programs/o3copy.zc
a
Diffstat (limited to 'tests/programs/o3copy.zc')
-rw-r--r--tests/programs/o3copy.zc12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/programs/o3copy.zc b/tests/programs/o3copy.zc
new file mode 100644
index 0000000..90b9ade
--- /dev/null
+++ b/tests/programs/o3copy.zc
@@ -0,0 +1,12 @@
+// copies of a variable that a loop reads again: the global pass reads the variable itself
+o3 int g(int n, int b) {
+ int s = 0, c = b, i = 0;
+ while (i < n) { c = b; s = s + c * 3 + i; i++; }
+ return s + c;
+}
+o3 int h(int n, int k) {
+ int a = k, t = 0, i = 0;
+ while (i < n) { t = t + a; if (t > 1000) t = t - 1000; a = k; i++; }
+ return t + a;
+}
+fn main() { put_n(g(1000, 7)); put_c(32); put_n(h(1000, 5)); put_c(10); return 0; }