Control flow
WAVE uses structured branches and loops. Each wave has its own program counter and active mask. Inactive lanes produce no architectural side effects.
Branches
Section titled “Branches”icmp_lt p1, r0, r1if p1 iadd r2, r2, r3else isub r2, r2, r3endifif runs the first path for lanes where the condition is true. else runs the other path for lanes that were active on entry. endif reconverges those lanes.
The emulator stores this state in each wave's control flow stack. Backends map the same behavior to their target's control flow mechanisms.
loop iadd r0, r0, r1 icmp_ge p1, r0, r2 break p1endloopbreak removes matching lanes from the loop. continue skips the rest of the iteration for matching lanes. endloop starts the next iteration for lanes that remain in the loop.
Predication
Section titled “Predication”An instruction predicate restricts the active lanes. Use @p1 through @p3, or their negated forms, to select lanes. A zero predicate selector with no negation means unpredicated execution. The register p0 remains writable for comparisons and control-flow operands.
@p1 device_store r0, r1Only active lanes with p1 set perform the store. Other lanes leave memory unchanged.
Wave independence
Section titled “Wave independence”Branches in one wave cannot change another wave's masks or control flow stacks. Workgroup barriers coordinate waves without sharing their branch state. See Encoding and execution invariants.
The specification requires support for at least 32 nested control flow levels. See WAVE v0.4 for the execution rules and limits.