interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / compiler / progs / df_order.osc

24 lines · 958 bytes Raw Blame History
1// entry: order
2// OSC-3 item 3 (drop flags): release order with conditional moves, asserted
3// by test_osc_compiler for k = 0, 1, 3 in the interpreter and natively:
4// k=0: alloc 1 2 3, release 2 (q), alloc 4 5, release 5 4 3 1 (p skipped)
5// k=1: alloc 1 2 3, release 1 (eata), alloc 4 5, release 5 4 3 2 (a skipped)
6// k=3: alloc 1 2 3, release 1, alloc 4, release 4 (eata), alloc 5, release 5 3 2
7struct P { x: u32, y: u32 }
8
9fn eata(a: own [u32; 2]) -> u32 { return a[0] + a[1]; }
10
11fn order(k: u32) -> u32 {
12 let a: own [u32; 2] = alloc(k);
13 let p: own P = P { x: k, y: 2 };
14 let b: own [u32; 2] = alloc(5);
15 let mut r: u32 = 0;
16 if k > 0 { r = eata(a); } else { let q: own P = p; r = q.x + q.y; }
17 let c: own [u32; 2] = alloc(7);
18 if k > 1 { if k > 2 { r = r + eata(c); } }
19 let d: own [u32; 2] = alloc(1);
20 return r + b[0] + d[0];
21}
22// expect-run: order 0 -> 8
23// expect-run: order 1 -> 8
24// expect-run: order 3 -> 26