fitzgen opened PR #13251 from fitzgen:wasmtime-idempotent-store-elimination to bytecodealliance:main:
This is a very particular subset of "dead-store elimination" that we can do without extending the static analysis at all (e.g. we do not need to show that the target store is post-dominated by another store to the same location in this case). The key idea is this: if our existing analysis tells us that a memory location L is currently known to contain the value
v0(such that we could do redundant-load elimination by removingv8 = load Land makingv8an alias ofv0) then we can removestore v0, Lbecause memory locationLalready contains that value. We also do not need to worry about traps because ifLalready has a known-value, that must have been from a load or store toLthat dominates our idempotentstoreinstruction, and if this idempotentstorewould trap, then the original load/store toLwould have already trapped first.This does not result in any statistically significant differences in Sightglass.
cc https://github.com/bytecodealliance/wasmtime/issues/4167
<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13251.
fitzgen requested uweigand for a review on PR #13251.
fitzgen requested alexcrichton for a review on PR #13251.
fitzgen requested wasmtime-core-reviewers for a review on PR #13251.
fitzgen unassigned uweigand from PR #13251 Implement idempotent-store elimination.
fitzgen requested cfallin for a review on PR #13251.
fitzgen unassigned alexcrichton from PR #13251 Implement idempotent-store elimination.
:thumbs_up: cfallin submitted PR review:
LGTM with minor tweaks -- thanks!
:speech_balloon: cfallin created PR review comment:
any reason to remove this comment?
:speech_balloon: cfallin created PR review comment:
likewise, any reason to remove this?
:speech_balloon: cfallin created PR review comment:
might be helpful to add a set of split stats (
alias_analysis_removed_load+alias_analysis_removed_store) here too, in case we want to see how effective this is whenever we have a good way of consuming stats!
:speech_balloon: cfallin created PR review comment:
This is technically true but block1 doesn't even branch to block2 (and there is no path from 1 to 2). A more interesting test might be one where we have stores in two blocks, one of which branches to another, but the second also has another side-entrance (another in-edge) -- something like:
block1: brif ..., block2, block3 block2: store jump block4 block3: jump block4 block4: store ; should not be removed
:memo: fitzgen submitted PR review.
:speech_balloon: fitzgen created PR review comment:
whoops, just got lost in the shuffle
fitzgen updated PR #13251.
fitzgen has enabled auto merge for PR #13251.
fitzgen added PR #13251 Implement idempotent-store elimination to the merge queue.
github-merge-queue[bot] removed PR #13251 Implement idempotent-store elimination from the merge queue.
fitzgen added PR #13251 Implement idempotent-store elimination to the merge queue.
:check: fitzgen merged PR #13251.
fitzgen removed PR #13251 Implement idempotent-store elimination from the merge queue.
Last updated: May 03 2026 at 22:13 UTC