pub fn optimize(graph: &SharedGraph, roots: &[NodeId]) -> Vec<NodeId>Expand description
Run CSE + algebraic simplification on the graph reachable from
roots. Returns the (possibly-rewritten) roots the caller should
use afterward.
The pass runs to a fixed point on a single topological walk: each node is visited once, canonicalized (inputs remapped, constants folded where trivial), then either matched to an existing canonical node (CSE) or appended as fresh. No multi-pass iteration — the simplification rules are chosen so one forward pass suffices.