#[repr(u8)]pub enum Opt {
Show 76 variants
Memo = 0,
Tco = 1,
Peephole = 2,
Borrow = 3,
Specialize = 4,
Comptime = 5,
Inline = 6,
Unfold = 7,
Defunctionalize = 8,
LoopHoist = 9,
Unroll = 10,
LoopSplit = 11,
ClosedForm = 12,
Fuse = 13,
LoopCse = 14,
Cse = 15,
DeadCode = 16,
Scalarize = 17,
Affine = 18,
Interleave = 19,
Unbox = 20,
HoistBorrows = 21,
Narrow = 22,
NarrowVm = 23,
NarrowMap = 24,
DenseMap = 25,
ElemType = 26,
FastDiv = 27,
FloatStrength = 28,
Oracle = 29,
OracleHints = 30,
Unchecked = 31,
Simd = 32,
Cascade = 33,
IndexString = 34,
CapScale = 35,
Symmetry = 36,
Popcount = 37,
Saturate = 38,
Supercompile = 39,
Sccp = 40,
IntStrength = 41,
RegPromote = 42,
Interchange = 43,
AccumBound = 44,
DivModFuse = 45,
SpecializeLoop = 46,
BignumByRef = 47,
BignumInPlace = 48,
BitIntrinsics = 49,
TextBytesView = 50,
StringAccumReuse = 51,
SimdReduce = 52,
TextFromBytesBuilder = 53,
TextSliceReturn = 54,
StringConcatReuse = 55,
StringRepeatLoop = 56,
AsciiClassMask = 57,
StrengthReducePow2 = 58,
BranchlessAccumulate = 59,
WideAccumulator = 60,
RadixDigitBuffer = 61,
ByteSliceReturn = 62,
Tile = 63,
MaskNarrow = 64,
ModWrap = 65,
BranchlessSelect = 66,
VariantBox = 67,
BitPack = 68,
FoldFusion = 69,
SortNest = 70,
DivisorSieve = 71,
TraceMemo = 72,
ProbeFuse = 73,
StrideFill = 74,
HintVersion = 75,
}Expand description
Every optimization the compiler can toggle. The discriminant is the bit
index used by OptimizationConfig, so the order here is stable and must
not be reordered casually (it also defines conflict-resolution precedence:
an earlier variant wins a conflict against a later one).
Variants§
Memo = 0
Automatic memoization of pure functions.
Tco = 1
Tail-call optimization (self-tail-recursion → loop).
Peephole = 2
Peephole rewrites (swap, vec-fill, for-range, …).
Borrow = 3
Read-only / mutable borrow inference: &[T] / &mut [T] / &str / &Enum params, and a loop that reads a
sequence it never writes through a shared borrow instead of a copy.
Specialize = 4
Partial evaluation / polyvariant specialization.
Comptime = 5
Compile-time function evaluation (CTFE).
Inline = 6
Inlining of tiny and leaf helper functions.
Unfold = 7
Bounded unrolling of recursive functions.
Defunctionalize = 8
Defunctionalization (closures → first-order functions).
LoopHoist = 9
Loop-invariant code motion (LICM).
Unroll = 10
Loop unrolling of constant-trip loops.
LoopSplit = 11
Guard-based loop index-set splitting (for vectorization).
ClosedForm = 12
Accumulator-loop → closed-form recognition.
Fuse = 13
Deforestation (producer/consumer stream fusion).
LoopCse = 14
Loop-carried common-subexpression hoisting.
Cse = 15
Global value numbering / common-subexpression elimination.
DeadCode = 16
Dead-code elimination.
Scalarize = 17
Fixed-size sequence scalarization (SROA).
Affine = 18
Affine offset-array deletion → closed-form indexing.
Interleave = 19
Array-of-structs interleaving of co-indexed sequences.
Unbox = 20
De-Rc: unique-owned sequences become plain Vec.
HoistBorrows = 21
Hoisting borrow live-ranges out of loop nests.
Narrow = 22
i64→i32 sequence element narrowing (codegen).
NarrowVm = 23
i64→i32 sequence element narrowing (VM).
NarrowMap = 24
i64→i32 map-key narrowing.
DenseMap = 25
Sparse map → dense direct-addressed array.
ElemType = 26
Element-type narrowing via abstract interpretation.
FastDiv = 27
Constant-divisor magic-reciprocal division.
FloatStrength = 28
Float induction-variable strength reduction.
Oracle = 29
Abstract interpretation / oracle-fact production (interval analysis).
OracleHints = 30
Oracle-derived precise bounds-check guards.
Unchecked = 31
Oracle-proven unchecked indexing (get_unchecked).
Simd = 32
SIMD-vectorized search kernels.
Cascade = 33
Cascade folding of sequential comparisons.
IndexString = 34
Indexed string-search codegen.
CapScale = 35
Capacity-scaling buffer-fill simplification.
Symmetry = 36
Reflection symmetry breaking (bitmask search).
Popcount = 37
Popcount base-case collapse for bitmask search.
Saturate = 38
Equality-saturation rewriting (e-graph).
Supercompile = 39
Supercompilation (heavy residual specialization, AOT only).
Sccp = 40
Sparse conditional constant propagation (Wegman–Zadeh): folds constants AND prunes unreachable branches in one lattice sweep, catching constants the iterated fold→propagate→deadcode pipeline structurally misses.
IntStrength = 41
Integer induction-variable strength reduction: a counted loop’s affine
coeff*j + base index (base loop-invariant) becomes a seeded accumulator
advanced by coeff*step, removing the per-iteration multiply. Exact
(no runtime guard).
RegPromote = 42
Aggregate-element register promotion: an invariant-indexed read-modify- write array element is loaded into a scalar once, updated in a register across the loop, and written back once — store-to-load forwarding LICM cannot do (the element is written).
Interchange = 43
Loop interchange: reorder two adjacent nested counted loops to put the
unit-stride access innermost (the ijk→ikj matmul recipe). Fires only
on integer commutative-reduction nests, where any permutation is
bit-identical, and only toward better locality.
AccumBound = 44
Bounded-accumulator overflow-guard elision: version a hot integer loop that
provably stays i64-safe under a compile-time input bound (interval
inductive-invariant check), so its fast branch lowers to bare i64 instead of
a per-iteration overflow-promotion guard; a huge input takes the unchanged
promoting branch (never an abort).
DivModFuse = 45
Div-mod fusion: rustc/LLVM does not CSE a/b against a%b (distinct sdiv/srem,
each its own magic-multiply for a constant divisor), so a loop computing both pays
two multiplies where gcc keeps the quotient and derives r = a - q*b. When one
statement holds both with the same side-effect-free operands, bind q = a/b once
and rewrite a%b -> a - q*b — the single-division shape, propagating proven-raw.
SpecializeLoop = 46
Range-aware helper specialization: a counted-accumulator loop calls pure integer
helpers (divModQ/divModM/…) whose bodies branch on argument SIGN, but the loop
counter is provably >= 0 and the divisor a positive constant, so those branches
are dead. This symbolically inlines the helper chain under the counter’s range and
folds the dead branches, leaving bare arithmetic the div-mod fuser + accumulator
versioner then lower to a hand-C-quality loop. A call that isn’t fully provable is
left untouched.
BignumByRef = 47
Bignum by-reference arithmetic (clone elision): a reused promoted (LogosInt) operand in
a +/-/* is passed by VALUE to logos_*_exact, so a variable read twice (or read then
reassigned) .clone()s its heap magnitude every iteration. LogosInt::{add,sub,mul} are
already (&self, &LogosInt), and logos_mul_exact(a,b) IS a.into().mul(&b.into()), so
the by-ref method is byte-identical minus the clone. Reused bignum vars are borrowed.
BignumInPlace = 48
In-place bignum scalar multiply: Set acc to acc * <i64> on a promoted accumulator (dead
last-use, native-int scalar) mutates acc’s heap Vec in place (acc.mul_assign_i64(k))
instead of allocating a fresh product each iteration (the factorial hot loop).
BitIntrinsics = 49
Native-width bit intrinsics: the stdlib rotateLeft/rotateRight/reverseBits/
reverseBytes with a compile-time native word width (8/16/32) lower to a single Rust
intrinsic ((x as uW).rotate_left(n) / .reverse_bits() / .swap_bytes()) — one CPU
instruction (ROL/ROR, bit-reverse, BSWAP) — instead of a masked loop LLVM cannot recognize.
Fires at the call site AND on the const-specialized masked-rotate form the optimizer folds to.
TextBytesView = 50
Text-bytes zero-copy view: a Let sb be text_bytes(s) binding used ONLY for reads
(item i of sb, length of sb, for b in sb) lowers to a borrowed s.as_bytes()
(&[u8]) instead of materializing a Vec<i64> byte-list (8x blow-up + Rc<RefCell>
box + a .borrow() and bounds check per byte). Reads cast the u8 back to i64.
The whole text stdlib funnels every operation through text_bytes, so this removes
the dominant text-cluster read cost. Read-side half of the byte-list elimination.
StringAccumReuse = 51
String accumulator reuse: Set X to X combined with Y (X a mutable owned String,
Y not mentioning X) mutates X’s buffer in place via X.push_str(&Y) — amortized O(1)
growth — instead of X = format!("{}{}", X, Y), which reallocates and copies the whole
accumulator every iteration (turning repeatText and any concat-accumulator loop into
O(N^2)). Fires on the SHAPE (self-append concat, target leftmost) so a user’s own
accumulator loop benefits identically. General FBIP write-side string reuse.
SimdReduce = 52
SIMD reduction: an integer accumulator loop summing trunc(<liftable float in the counter>)
over a counted range is lowered to an AVX2 four-lane f64 reduction — the transcendental is
translated to _mm256 intrinsics (branches → blendv), byte-identical to the scalar path
per lane, and the i64 sum is associative so the reduce equals the sequential sum. Beats
scalar libm across the loop where LLVM refuses to auto-vectorize the f64→i64 cast.
TextFromBytesBuilder = 53
Text write-side byte builder: a Let out be a new Seq of Int used ONLY as a byte builder
(Push <i64> to out) and consumed by text_from_bytes(out) lowers to a bare Vec<u8>
(out.push((e) as u8)) plus a direct String::from_utf8(out) — eliminating the
Rc<RefCell<Vec<i64>>> output (8x memory + per-push borrow_mut + no presize) AND the
separate i64->u8 rebuild pass that text_from_bytes performed. Write-side half of the
byte-list elimination (twin of TextBytesView); fires on the SHAPE so any user byte-builder
benefits identically.
TextSliceReturn = 54
Text zero-copy sub-slice return: a fn that returns a CONTIGUOUS sub-slice of a borrowed Text
param (compute lo/hi by scans, then copy item lo..hi of text_bytes(s) into a builder and
text_from_bytes(out)) lowers to a borrowed &'a str return (fn f<'a>(s: &'a str) -> &'a str { &s[lo-1..hi] }) when EVERY caller uses the result read-only (never binds/returns/pushes it).
Matches Rust str::trim/strip_prefix — an O(1) fat-pointer slice instead of an O(n) copy.
Requires the Text param already borrowed (Opt::Borrow); PREEMPTS the write-side builder on the
terminal Return (the slice supersedes building a Vec
StringConcatReuse = 55
String concat reuse (Let-form): Let X be A + B... where A is a fresh OWNED String (a call
returning String) reuses A’s buffer — let mut X = A; X.push_str(&B)... — instead of
format!("{}{}", A, B), which allocates a NEW String and copies every operand. The Let-form
twin of StringAccumReuse (which handles Set X to X + Y). Construction-shared across the whole
text benchmark cluster (repeatText(..) + base), so it lifts trim/upper/lower/… toward Rust’s
buffer-reuse ("a".repeat(k) + &base). Fires on the SHAPE; a user’s A + B benefits identically.
StringRepeatLoop = 56
String repeat-idiom: Let out be "" + a counted loop whose sole body is Set out to out + chunk
(chunk loop-invariant) lowers to let out = chunk.repeat(count) — one presized alloc + memset,
matching Rust’s chunk.repeat(n), instead of count un-presized push_stres. Fires on the
SHAPE (a counted append of a fixed chunk), so repeatText and any user repeat-loop benefit.
AsciiClassMask = 57
ASCII-class bitmask: a pure Int -> Bool predicate whose true-set lies entirely in the byte
domain [0,256) (the charIs* family — range/equality checks over c) lowers to a branchless
256-bit mask test (0<=c<256) && (MASK[(c>>6)&3] >> (c&63)) & 1, built by CTFE-evaluating the
predicate over 0..256. Beats C’s ctype table (the mask is an immediate/static — no memory
load). Fires on ANY such predicate, so a user’s classifier collapses the same way.
StrengthReducePow2 = 58
Power-of-two modulo/division strength reduction: x % 2^k → x & (2^k-1) and x / 2^k →
x >> k when x is proven non-negative (a loop counter from a >= 0 start with a positive
step). rustc keeps sign-corrected %// for a runtime i64 (several instructions that also
block auto-vectorization); the mask/shift is one op. Sound (for x >= 0 they agree), general
(every ring-buffer/hash/index loop), and the measured lever that lets loops beat C.
BranchlessAccumulate = 59
Branchless accumulate (predicate-guarded increment if-conversion): if <cond> { X = X + k }
(no else, X a plain integer accumulator, k a literal) → X = X + (<cond> as i64) * k. Removes
the data-dependent branch that blocks the loop vectorizer. Byte-identical (cond ∈ {0,1}, and
cond is evaluated exactly once either way). Pairs with a wide accumulator to beat C’s count.
WideAccumulator = 60
Wide (i128) accumulator: a Let X be 0 counting accumulator incremented ONLY by +1 (guarded
or not) in a SINGLE counted loop with an i64 bound, read ONLY by Show X, widens to i128 for
the loop — the plain i128 add has no overflow branch (unlike logos_add_i64), so the count
vectorizes. SOUND: X ≤ trip-count ≤ i64::MAX, so it fits i64 (narrow as i64 at the sink is
exact) and i128 can’t overflow. The lever that beats C’s ctype-count loop (43ms vs 49ms).
RadixDigitBuffer = 61
Radix digit buffer (itoa): the base-N integer→text idiom (generate digits LSB-first into a
boxed Seq, reverse into a second boxed Seq, text_from_bytes) lowers to ONE fixed-size
stack [u8; 64] written BACK-TO-FRONT (the back-to-front write is the reversal), then one
String from the buffer tail — no heap Seq, no reversal copy. SOUND only when the loop
counter is a native i64 (never bignum-promotable) so the digit count is bounded ≤64. Beats
Go’s strconv (measured 1.30x). Preempts TextFromBytesBuilder (it eliminates the out
byte-builder that pass would otherwise lower).
ByteSliceReturn = 62
Byte-slice return (the bytes-trim family): a fn taking a Seq of Int param that returns a
CONTIGUOUS lo..=hi sub-slice (scan, then copy item lo..hi of xs into out, Return out)
lowers to a borrowed &'a [i64] (fn f<'a>(xs: &'a [i64], …) -> &'a [i64] { … &xs[lo-1..hi] })
— Go’s O(1) bytes.Trim reslice instead of the O(n) build-copy. The bytes twin of
TextSliceReturn (a readonly Seq param is already &[i64], so the sub-slice shares its
lifetime). Caller-gate drops any fn whose result escapes. Preempts OracleHints + Unchecked
(eliminates the indexed-copy loop those bounds-check opts would optimize). Requires Borrow.
Tile = 63
Loop tiling: a band of counted loops runs in square tiles for cache locality, only where the dependence
test proves no run can tell the order apart (optimize::dependence), the nest versioned on the
preconditions that make it so (optimize::version). The order of every item’s own updates is kept, so a
Real accumulation stays bit for bit.
MaskNarrow = 64
Masked-chain narrowing: an integer chain of +, -, *, &, |, ^ and constant << under a low-bit
mask & (2^k - 1), k <= 32, whose every node the range oracle proves stays an i64, computes in 32-bit
wrapping arithmetic. That is exact: those operations’ low k bits depend only on their operands’ low k
bits. Narrowed, a masked LCG’s unrolled steps become independent multiplies (by a, a², a³, a⁴) instead of one
serial 64-bit multiply chain.
ModWrap = 65
A remainder by a constant m > 0 of a value the range oracle bounds to [0, 2m): x - m when x >= m, and
x otherwise, one compare and one subtract in place of a multiply-shift remainder (a value bounded below m
is its own remainder). A loop that carries a residue (b = (a + b) % M) has its remainder on the critical
path, so the subtraction bounds the loop instead of the division. On the bytecode path the VM compiler decides
it from the same oracle: a value below m compiles as itself, and one below 2m keeps its magic remainder
marked wrap, which the VM and the C walker compute as the compare and subtract.
BranchlessSelect = 66
Branchless select: If c: Set x to a. Otherwise: Set x to b., where both arms are integer arithmetic that
cannot trap and at least one keeps its exactness behind a guarded dual, computes both arms and lets c choose
(a conditional move, not a branch on c). The arms’ guards are tested on their own before either arm; when one
fails, the original branch runs with its exact arithmetic. A data-dependent c (collatz’s parity) no longer
mispredicts.
VariantBox = 67
Variant boxing: a variant of a recursive enum that holds the enum itself keeps all its fields in one box (the
variant’s payload, a struct of them), where each recursive field had a box of its own; a variant with no
fields is a value with no allocation. A tree of n leaves allocates once per node rather than once per child,
a leaf included: OCaml’s representation of a datatype.
BitPack = 68
Bit packing: a local Seq of Bool used only through item reads, item stores, pushes and its length is held one
bit per item (LogosBits), an eighth of the bytes of a Vec<bool>; a sieve’s table of 10^8 flags fits the
cache its passes streamed through.
FoldFusion = 69
Fold/build fusion: a function that only takes a datatype apart, applied to what a function builds of it, is
one function that never builds it (the builder’s recursion, each construction replaced by the consumer’s arm for
that variant). check(bottomUpTree(d)) builds no tree, and the fused recursion is a shape the compiler
collapses.
SortNest = 70
Sorting-nest collapse: a nest of passes of adjacent compare-exchanges over a sequence of Ints (bubble sort)
that has enough passes to sort its window is one in-place heap sort of the window, behind a hoisted check
that the passes suffice and the window lies inside the sequence; n(n-1)/2 comparisons become O(n log n).
DivisorSieve = 71
Divisor sieve: a search, for each number of a counted range, for a divisor no greater than its square root
(trial division) reads one sieve of the range, marked before the loop, behind a guard on the sieve’s size;
O(n sqrt n) divisions become O(n log log n) marks.
TraceMemo = 72
Trace memoization: a pure iteration run from every start of a counted range, whose only effect adds a constant to an accumulator, keeps what each finished start added in a table, and a trace that reaches a finished start adds that start’s sum and stops.
ProbeFuse = 73
Probe fusion: If m contains k: over a branch that reads item k of m reads the value once at the top of
the branch, and the test and the read are one lookup.
StrideFill = 74
Strided fill: a loop that stores one value into a bit-packed Seq of Bool at a fixed stride, every store
proven to name an item and the stride at least 1, is one fill that writes each word once (a sieve crossing
off a small prime’s multiples sets dozens of bits per word).
HintVersion = 75
Hint versioning: the innermost loop whose bounds hints the Oracle could not discharge runs as two copies, one that assumes every hint, chosen where every hint holds, and one that assumes none.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Opt
impl<'de> Deserialize<'de> for Opt
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Opt
impl Ord for Opt
Source§impl PartialOrd for Opt
impl PartialOrd for Opt
impl Copy for Opt
impl Eq for Opt
impl StructuralPartialEq for Opt
Auto Trait Implementations§
impl Freeze for Opt
impl RefUnwindSafe for Opt
impl Send for Opt
impl Sync for Opt
impl Unpin for Opt
impl UnsafeUnpin for Opt
impl UnwindSafe for Opt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.