Skip to main content

Module opt

Module opt 

Source
Expand description

Optimization pipeline primitives (spec §10.2): constant folding + common-subexpression elimination over the hash-consed ExprDAG.

Functions§

const_fold
Constant folding (spec §10.2 item 1): runs the simplify engine over the DAG and returns the canonical folded expression. Level-2 rules (0x, 1x, constant arithmetic, math constants) already live in crate::simplify::simplify.
cse
CSE (spec §10.2 item 3): returns the canonical ExprId for a subexpression. Because the ExprPool hash-conses identical nodes, repeated subexpressions already share one ExprId; this function documents and asserts that invariant (returns id unchanged). It exists as the stable entry point the JIT pipeline calls before codegen.
optimize
Full local optimization run (spec §10.2): const_fold then cse. Used by the JIT compiler before translating the DAG to bytecode.