LEGACY DOCS · 12.4Stable is 13.2. This page stays because it still owns historical or unchanged contracts.CURRENT 13.2 →
RELEASE LINE13.2 HISTORICAL13.1 PREDECESSOR13.0 PREVIOUS12.4 NATIVE MIRARCHIVE

LEGACY DOCS · 12.4

PAGE ROLE · OPTIMIZATION CONTRACT

O1 IS ALLOWED TO BE CLEVER. IT IS NOT ALLOWED TO BE CREATIVE.

DBYTE has two native optimization levels in v12.4. O0 keeps the machine path plain for diagnosis. O1 is the production default. Both consume the same Native MIR and both are bound by the same language, ownership, fault and ABI contracts.

00 one level for the whole compile

--opt-level 0 and --opt-level 1 select the native optimization policy at compile time. O1 is the default. The level is not secretly changed halfway through a function and standalone linking does not re-optimize already-produced objects.

That matters for reproducibility. If a user asks for O0, the compiler should not decide that one “obvious” transform is harmless and do it anyway. Debug configurations are useful because they are boring.

10 the O1 pass order is fixed

  1. CFG cleanup.
  2. Constant and copy propagation.
  3. Dead pure temporary elimination.
  4. Bounded local common-subexpression elimination.
  5. Alias-safe memory forwarding.
  6. Address and immediate folding.
  7. Compare/branch fusion.
  8. Constant branch simplification.
  9. Fault-preserving arithmetic strength reduction.
  10. Post-selection peepholes.

The fixed order is not a decoration in the documentation. Pass order is part of determinism. Moving a transform earlier can expose different opportunities, alter register pressure or change whether a later fold fires.

An optimizer that changes its mind because a hash table iterated differently is not optimizing. It is rolling dice with your binary.

20 dead values and common work

A dead temporary can disappear only when producing it has no required effect. A repeated expression can be reused only inside the bounded region where its operands and memory dependencies are still valid. “Nobody reads the result” is not enough if evaluating the expression can fault, allocate, call user code or mutate state.

30 memory forwarding needs alias proof

The attractive optimization is simple: store a value, then load the same address, so reuse the stored value. The dangerous part is everything between those operations. A call, overlapping store, volatile access or unknown alias can invalidate the assumption. DBYTE therefore treats memory forwarding as an alias-sensitive transform, not a textual pattern replacement.

40 faults are observable

Division by zero, bounds failure, borrow failure and other defined error points cannot be moved across observable work merely to save instructions. Arithmetic strength reduction must preserve fault behavior. Turning a division into something cheaper is legal only when the transformed sequence faults and produces values under the same contract.

This also applies to ownership. Cleanup, Drop, allocator events and calls are not “noise” around the arithmetic. They are program behavior.

OPTIMIZER LAW. Faster wrong code is wrong code. The benchmark does not get to pardon it.

50 compare and branch

When a comparison exists only to feed a branch and the target can express that relation directly, O1 may fuse the pair. Constant branches can collapse when their condition is already proven. CFG cleanup then removes dead edges and blocks. The result should be less control-flow machinery, not a new semantic interpretation.

60 peepholes are last, local and bounded

Post-selection peepholes see actual machine instruction forms. They can remove redundant moves, fold legal instruction patterns and clean up artifacts created by earlier lowering. They do not reopen whole-program reasoning. Keeping peepholes local makes them inspectable and keeps target quirks from leaking backward into Native MIR.

70 why O0 still matters

O0 is an oracle for structure. When O1 miscompiles a case, the useful comparison is not “does the VM work?” alone. Dump O0 Native MIR, dump O1 Native MIR, compare selected instructions, then narrow the first point where semantics diverge. A small optimizer is only a win if you can bisect it in your head.

80 next wire

Optimization produces virtual-register pressure. Read deterministic allocation to see how those values become registers and stack slots, then inspect the emitted machine state.