; Every read-modify-write returns the old value; add.wrap and sub.wrap are modular; bool cells take xchg, and, or, xor. ; expect: run ; result: 10 ; phase: 5 ; spec: docs/spec/04-concurrency-and-atomics.md module test.atomic_rmw_ops air 0 lang 0.1 features [atomics, effects, ownership] fn @main() -> u8 effects [atomic] entry: %z = const.u8 0 %c = atomic.new %z %r = borrow.ref %c %one = const.u8 1 %o1 = atomic.sub.wrap.seq_cst %r, %one %v6 = const.u8 6 %o2 = atomic.xchg.seq_cst %r, %v6 %v3 = const.u8 3 %o3 = atomic.and.seq_cst %r, %v3 %v8 = const.u8 8 %o4 = atomic.or.seq_cst %r, %v8 %o5 = atomic.xor.seq_cst %r, %v3 %o6 = atomic.add.wrap.seq_cst %r, %one borrow.end %r %final = atomic.take %c %e1 = const.u8 255 %k1 = eq.u8 %o2, %e1 assert %k1 %e2 = const.u8 2 %k2 = eq.u8 %o4, %e2 assert %k2 %t = const.bool true %b = atomic.new %t %rb = borrow.ref %b %ob = atomic.xor.seq_cst %rb, %t borrow.end %rb %fb = atomic.take %b assert %ob %nf = xor.bool %fb, %t assert %nf ret %final