Skip to content

Selection logic can miss optimisations due to non-simple subexpressions #3480

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

Open
lpw25 opened this issue Jan 16, 2025 · 0 comments
Open

Selection logic can miss optimisations due to non-simple subexpressions #3480

lpw25 opened this issue Jan 16, 2025 · 0 comments

Comments

@lpw25
Copy link
Collaborator

lpw25 commented Jan 16, 2025

I was just writing a patch that generated cmm code and ran into an issue with the selection logic that I think is worth fixing at some point. Currently if you generate:

(+ (<< e 1) 1))

for some expression e then the shift and add will only be optimised if e is a "simple expression". This is due to the logic of emit_parts which doesn't really do the right thing. It should pull out all the "non-simple" parts of an expression so that what remains is a simple expression. Instead it checks that the expression is simple deeply and then either treats it all as simple or none of it as simple. More generally, this whole area seems like it could be made much more robust by separating out the simple expressions from the non-simple ones at the type level, and ensuring that all selection patterns operate only on simple expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant