Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile integer patterns to a switch instead of a nested if/else tree #790

Open
yorickpeterse opened this issue Dec 23, 2024 · 0 comments
Open
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module

Comments

@yorickpeterse
Copy link
Collaborator

Description

When matching against an Int, we currently compile the possible cases to what's essentially a nested if/else tree. However, LLVM's switch instruction works perfectly fine for integers that aren't contiguous. Compiling to a switch means LLVM might be able to better optimize the code based on the values we're matching against. This does require that on the MIR level we distinguish between exhaustive switches (as used for enum tags) and non-exhaustive switches.

Related work

No response

@yorickpeterse yorickpeterse added compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module labels Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module
Projects
None yet
Development

No branches or pull requests

1 participant