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

CSE join: canonicalise the primitives in both environments #3182

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lthls
Copy link
Contributor

@lthls lthls commented Oct 24, 2024

Fixes #3181.

As explained in a comment there, when joining CSE equations we want to transform equations at the use site into equations at the join site (in the env at fork). There are multiple ways to do that: all aliases of primitive arguments that are in scope in the env at fork could be considered, which would yield the most precise result but risks exploding the number of CSE equations.
Before this PR we canonicalise in the environment at use, which handles the cases where primitives were called on local aliases of a "global" variable.
But we're failing in cases like the one from #3181, where a CSE equation is common to all branches but some branches have equations that change which element is canonical.
So this PR proposes to canonicalise in the env at fork in addition to the env at use. This potentially doubles the number of primitives, but in the common case where the branch doesn't introduce new relevant aliases the primitives are the same (using EP.Set.t to represent these possibilities means we don't actually have to check that manually).

@lthls lthls added the flambda2 Prerequisite for, or part of, flambda2 label Oct 24, 2024
@lthls
Copy link
Contributor Author

lthls commented Oct 24, 2024

@mshinwell You will probably want to look at this, although we should also discuss with @chambart next Tuesday.

@mshinwell
Copy link
Collaborator

Let's add some more documentation about the subtleties of CSE as discussed. I will approve now, just merge once that's done.

@lthls
Copy link
Contributor Author

lthls commented Oct 30, 2024

After some more discussions, it looks like there is a deeper problem that we need to think about properly. Since the bug report doesn't come for real code, we're putting this PR on hold until we have a better idea of how to solve the problem correctly.

@lthls lthls marked this pull request as draft October 30, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flambda2 Prerequisite for, or part of, flambda2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missed CSE opportunity
2 participants