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

Pattern guard desugaring inserts unnecessarily redundant tests #4497

Open
natefaubion opened this issue Aug 3, 2023 · 0 comments
Open

Pattern guard desugaring inserts unnecessarily redundant tests #4497

natefaubion opened this issue Aug 3, 2023 · 0 comments

Comments

@natefaubion
Copy link
Contributor

Description

Normal boolean guards are pushed down to the appropriate branch of the pattern match tree, such that falling through to the next guard does not entail rechecking the pattern. When pattern guards are involved, however, the desugaring duplicates the parent pattern into the continuation, resulting in unnecessarily duplicated tests.

To Reproduce

Steps to reproduce the behavior.

This try PureScript shows a redundant test against Just. The problem seems to be that it's sharing one continuation in both cases, when it could be splitting it into two continuations. In reality, this case is simple enough that no continuation should be necessary at all.

Expected behavior

Ideally, #4496 would solve this issue for backend-optimizer, as we could compile the guards as part of our existing pattern match optimizer, but I think the main compiler should also try to avoid these redundant tests.

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

No branches or pull requests

1 participant