Repository navigation
JIT: Elide adjacent Wasm local set/get pairs at known last uses - #137199
Merged
Merged
Conversation
Peephole optimize 'local.set N; local.get N; ' -> '' if the get is known to be the last use of the local. Instead the value is just left on the stack. Preserve multiply-used candidate-local information into codegen since those locals may not have an obvious last use. Contributes to dotnet#135985. Co-authored-by: Copilot <[email protected]> Copilot-Session: 1da7d7aa-79b4-4ae1-ae4a-9861fdf9681c
|
Azure Pipelines: Successfully started running 6 pipeline(s). 9 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
@adamperlin PTAL Small improvement in code size. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
adamperlin
reviewed
Nov 9, 2026
adamperlin
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Peephole optimize
local.set N; local.get Naway when the get is known to be the last use. Leave the value on the operand stack instead.Preserve multiply-used candidate-local information into codegen, since one IR use can emit multiple reads. Keep elided instruction descriptors as zero-byte placeholders to preserve debug and GC instruction positions.
Size
Havit composite R2R:
SuperPMI replayed 38,469 contexts successfully with both JITs: 7,346 smaller, none larger. One context with identical missing collection data on both JITs was excluded. Size figures use code-byte metrics; the Wasm native differ also produces false size-neutral reports.
Validation
build.cmd clr.crossarchtools -os browser -arch wasm -c Release /p:RuntimeFlavor=CoreCLRpassed.Contributes to #135985.
Note
This PR description was generated with GitHub Copilot.