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

[NFC] Avoid quadratic time when precomputing blocks #6862

Merged
merged 6 commits into from
Aug 21, 2024

Conversation

kripken
Copy link
Member

@kripken kripken commented Aug 21, 2024

When precomputing fails on a child block of a parent block, there is no point
to precompute the parent, as that will fail as well.

At least, I can't think of any instruction sequence in wasm that could cause that
(see detailed comment in the code). I also fuzzed this (see second commit,
which is later reverted), and failed to find anything after a few thousand
iterations. But in theory this is not NFC if there is something that could be
optimized.

This makes --precompute on Emscripten's test_biggerswitch go from 1.44
seconds to 0.02 seconds (not a typo, that is 72x faster). The absolute number
is not that big, but we do run this pass more than once, so it saves a noticeable
chunk of time.

@kripken kripken requested a review from tlively August 21, 2024 18:54
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % clarifying the example in the comment.

Comment on lines 405 to 407
// (br $out)
// )
// (undo that side effect exactly, and nothing more)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This br would skip over the undo of the side effects, so I don't think this example makes sense.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed.

@kripken kripken merged commit 2d99e10 into WebAssembly:main Aug 21, 2024
13 checks passed
@kripken kripken deleted the noquad.precomp branch August 21, 2024 23:13
@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