Function fold_constants_fixpoint

Source
pub fn fold_constants_fixpoint(limit: bool) -> Fixpoint
Expand description

Does constant folding to a fixpoint: An expression all of whose leaves are constants, of size small enough to be inlined and folded should reach a single MirRelationExpr::Constant.

If limit is false, it does constant folding even on large constants.

This needs to call FoldConstants together with NormalizeLets in a fixpoint loop, because currently FoldConstants doesn’t inline CTEs, so these two need to alternate until fixpoint.

Also note that FoldConstants can break the normalized form by removing all references to a Let.

We also call ReduceScalars, because that does constant folding inside scalar expressions.