Function mz_transform::normalize_lets::let_motion::harvest_non_recursive
source · pub(crate) fn harvest_non_recursive(
expr: &mut MirRelationExpr,
) -> BTreeMap<LocalId, (MirRelationExpr, Option<LetRecLimit>)>
Expand description
Harvest any safe-to-lift non-recursive bindings from a LetRec
expression.
At the moment, we reason that a binding can be lifted without changing the output if both:
- It references no other non-lifted binding bound in
expr
, - It is referenced by no prior non-lifted binding in
expr
.
The rationale is that (1) ensures that the binding’s value does not change across iterations, and that (2) ensures that all observations of the binding are after it assumes its first value, rather than when it could be empty.