| 30 | 30 | ### The simplifier (issue #196) |
| 31 | 31 | To a fixed point, per function: |
| 33 | +- **Inlining:** a direct call of a small non-recursive function (a node-count threshold), or of a known lambda called once, becomes the body; a call in tail position stays in tail position. Wrappers (a function that only calls another) are always inlined. Recursive functions are never inlined. Inlining stays **within a module** (ADR 0029): a unit's C must not come to depend on another module's body, or an edit there would recompile it — cross-module calls are specialisation's and fusion's business (issues #197, #198), whose copies have a unit of their own. |
| 34 | 34 | - **Case-of-known-constructor:** a `switch` on a value built in the same function takes its branch at compile time; a projection of a known construction becomes the field. |
| 35 | 35 | - **Dead lets and sinking:** a `let` of a pure value nothing uses is removed; a pure `let` sinks toward its single use — never across an effect, a `perform` or a `handle`. (Sinking pure code past a call is sound: pure code is unobservable, and its divergence is imprecise, below. The C backend's yield checks come later, on code whose effect order is fixed here.) |
| 36 | 36 | - **Copy propagation:** `let v = u` substitutes. |