lean4-htt/src/Lean/Compiler/LCNF
Rob23oba 9b7a8eb7c8
perf: improve over-applied cases in ToLCNF (#12284)
This PR changes the handling of over-applied cases expressions in
`ToLCNF` to avoid generating function declarations that are called
immediately. For example, `ToLCNF` previously produced this:
```lean-4
set_option trace.Compiler.init true
/--
trace: [Compiler.init] size: 4
    def test x y : Bool :=
      fun _y.1 _y.2 : Bool :=
        cases x : Bool
        | PUnit.unit =>
          fun _f.3 a : Bool :=
            return a;
          let _x.4 := _f.3 _y.2;
          return _x.4;
      let _x.5 := _y.1 y;
      return _x.5
-/
#guard_msgs in
def test (x : Unit) (y : Bool) : Bool :=
  x.casesOn (fun a => a) y
```
which is now simplified to
```lean-4
set_option trace.Compiler.init true
/--
trace: [Compiler.init] size: 3
    def test x y : Bool :=
      cases x : Bool
      | PUnit.unit =>
        let a := y;
        return a
-/
#guard_msgs in
def test (x : Unit) (y : Bool) : Bool :=
  x.casesOn (fun a => a) y
```
This is especially relevant for #8309 because there `dite` is defined as
an over-applied `Bool.casesOn`.
2026-02-06 09:27:15 +00:00
..
Simp refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
AlphaEqv.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
AuxDeclCache.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
BaseTypes.lean chore: remove redundant imports in core (#10750) 2025-10-16 20:27:46 +00:00
Basic.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
Bind.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
Check.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
Closure.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
CompatibleTypes.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
CompilerM.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
ConfigOptions.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
CSE.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
DeclHash.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
DependsOn.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
ElimDead.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
ElimDeadBranches.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
ExtractClosed.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
FixedParams.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
FloatLetIn.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
FVarUtil.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
InferType.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
Internalize.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
Irrelevant.lean feat: zero cost BaseIO (#10625) 2025-10-22 10:55:12 +02:00
JoinPoints.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
LambdaLifting.lean Revert "chore: temporarily disable proofs for bootstrap" 2026-02-05 13:41:34 +11:00
LCtx.lean refactor: port push_proj to LCNF (#12294) 2026-02-03 19:21:45 +00:00
Level.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
LiveVars.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
Main.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
MonadScope.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
MonoTypes.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
OtherDecl.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
Passes.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
PassManager.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
PhaseExt.lean perf: put the compiler off the critical path (#12335) 2026-02-05 20:39:11 +00:00
PrettyPrinter.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
Probing.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
PublicDeclsExt.lean perf: put the compiler off the critical path (#12335) 2026-02-05 20:39:11 +00:00
PullFunDecls.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
PullLetDecls.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
PushProj.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ReduceArity.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
ReduceJpArity.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
Renaming.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
ResetReuse.lean refactor: reset reuse pass to LCNF (#12315) 2026-02-05 15:54:46 +00:00
ScopeM.lean refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Simp.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
Specialize.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
SpecInfo.lean refactor: introduce a phase separation to the IR (#12214) 2026-01-30 09:42:29 +00:00
SplitSCC.lean feat: lambda pure conversion in LCNF (#12272) 2026-02-03 10:24:59 +00:00
StructProjCases.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ToDecl.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ToExpr.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ToImpure.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ToImpureType.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
ToLCNF.lean perf: improve over-applied cases in ToLCNF (#12284) 2026-02-06 09:27:15 +00:00
ToMono.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
Types.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
Util.lean chore: shake core (#12276) 2026-02-05 09:10:32 +00:00
Visibility.lean perf: put the compiler off the critical path (#12335) 2026-02-05 20:39:11 +00:00