pub fn recognize_expr(e: &Expr) -> Option<Quad2>Expand description
Lower an Expr to a Quad2, or None if it contains anything the
recognizer cannot prove is a degree-≤2 polynomial (transcendental ops,
division by a non-constant, Pow with an exponent ∉ {0, 1, 2}, products
of degree > 2, external calls, comparisons, if-then-else, min/max,
…). None ⇒ treat as general nonlinear.
Cse nodes are inlined: a reference is mathematically its body, and
every reference is an independent occurrence. A body is nevertheless
lowered once, and its Quad2 reused at every later reference
(keyed on Arc identity). That is what makes the walk Θ(nodes) on a
shared DAG instead of Θ(2^depth); Q4 had to refuse a re-referenced
body outright to bound the cost, and this is the memoization that
refusal was waiting for (gh #588, Q5). It is bitwise neutral — the
lowering of a body is a function of the body, so the reused value is
the one a second lowering would have produced, bit for bit.
The walk is iterative. See the module docs for why that is a correctness property and not a style choice.