Skip to content

Conversation

@hargoniX
Copy link
Contributor

@hargoniX hargoniX commented Dec 5, 2025

This PR makes the LCNF simplifier eliminate cases where all alts are .unreach to just an .unreach.
an .unreach

We considered dropping a cases in a situation like this but decided against it because it might hinder reuse.

def test x : Bool :=
  cases x : Bool
  | Except.error a.1 =>
    ⊥
  | Except.ok a.2 =>
    let _x.3 := true;
    return _x.3

@hargoniX hargoniX requested a review from leodemoura as a code owner December 5, 2025 16:37
@hargoniX hargoniX added the changelog-compiler Compiler, runtime, and FFI label Dec 5, 2025
@hargoniX
Copy link
Contributor Author

hargoniX commented Dec 5, 2025

!bench

@leanprover-radar
Copy link

leanprover-radar commented Dec 5, 2025

Benchmark results for 234a789 against 76f32e2 are in! @hargoniX

Minor changes (1)
  • 🟥 big_do//instructions: +245.6M (+0.8%)

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Dec 5, 2025
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 76f32e22734d99e81cc1a6f5380bdb5c7d34e689 --onto 455fd0b4488e2adc85f825a52e2ee7d944a5740a. You can force Mathlib CI using the force-mathlib-ci label. (2025-12-05 17:45:49)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 76f32e22734d99e81cc1a6f5380bdb5c7d34e689 --onto d3dda9f6d4428a906c096067ecb75e432afc4615. You can force reference manual CI using the force-manual-ci label. (2025-12-05 17:45:50)

@hargoniX hargoniX force-pushed the hbv/simp_kill_single_exit_cases branch from 234a789 to abd96f6 Compare December 5, 2025 20:20
@hargoniX hargoniX changed the title perf: eliminate cases with a single exit perf: eliminate cases with all branches unreachable Dec 5, 2025
@hargoniX hargoniX enabled auto-merge December 5, 2025 20:21
@hargoniX hargoniX added this pull request to the merge queue Dec 5, 2025
Merged via the queue into master with commit c5e0417 Dec 5, 2025
20 checks passed
algebraic-dev pushed a commit that referenced this pull request Dec 8, 2025
This PR makes the LCNF simplifier eliminate cases where all alts are
`.unreach` to just an `.unreach`.
  an `.unreach`

We considered dropping a cases in a situation like this but decided
against it because it might hinder reuse.
```
def test x : Bool :=
  cases x : Bool
  | Except.error a.1 =>
    ⊥
  | Except.ok a.2 =>
    let _x.3 := true;
    return _x.3
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-compiler Compiler, runtime, and FFI toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants