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

LocalCSE: Check effects/generativity early #6587

Merged
merged 4 commits into from
May 14, 2024
Merged

Conversation

kripken
Copy link
Member

@kripken kripken commented May 13, 2024

Previously we checked late, and as a result might end up failing to optimize when
a sub-pattern could have worked. E.g.

(call
  (A)
)
(call
  (A)
)

The call cannot be optimized, but the A pattern repeats. Before this PR we'd
greedily focus on the entire call and then fail. After this PR we skip the call
before we commit to which patterns to try to optimize, so we succeed.

Add a isShallowlyGenerative helper here as we compute this step by step as
we go. Also remove a parameter to the generativity code (it did not use the
features it was passed).

@kripken kripken requested review from tlively and aheejin May 13, 2024 23:20
@kripken
Copy link
Member Author

kripken commented May 14, 2024

Fuzzed all night without issues.

@kripken kripken merged commit 4ca05f7 into WebAssembly:main May 14, 2024
13 checks passed
@kripken kripken deleted the why.cse.3 branch May 14, 2024 17:10
kripken added a commit that referenced this pull request May 15, 2024
#6587 was incorrect: It checked generativity early in an incremental manner, but
it did not accumulate that information as we do with hashes. As a result we
could end up optimizing something with a generative child, and sadly we lacked
testing for that case.

This adds incremental generativity computation alongside hashes. It also splits
out this check from isRelevant.

Also add a test for nested effects (as opposed to generativity), but that already
worked before this PR (as we compute effects and invalidation as we go, already).
@gkdn gkdn mentioned this pull request Aug 31, 2024
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

Successfully merging this pull request may close these issues.

2 participants