Skip to content

JIT: Reuse destination locals as CSE temporaries - #137838

Open
NinoFloris wants to merge 2 commits into
dotnet:mainfrom
NinoFloris:jit/cse-store-local-temp
Open

NinoFloris wants to merge 2 commits into
dotnet:mainfrom
NinoFloris:jit/cse-store-local-temp

Conversation

@NinoFloris

@NinoFloris NinoFloris commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Reuse the local receiving a single CSE definition, preserving its store and SSA name and extending liveness to the replacement uses.

For locals with other definitions, walk backward from each replacement use, including across loop backedges. Reuse the local only if the first store to it on every incoming path is the CSE definition. Use a fresh temp if a path reaches another store or method entry first, or if the method has EH. This check matters because pruned SSA can omit a phi at a join where the local was dead before CSE added the use.

CI results, aggregated across collections. PerfScore is the geomean over all paired compilations; lower is better in every column.

Platform TP Code size PerfScore (geomean)
Linux x64 -0.053% -364,034 B -0.013%
Windows x64 -0.077% -531,318 B -0.018%
Linux arm64 -0.102% -700,512 B -0.026%
Windows arm64 -0.101% -661,304 B -0.028%
macOS arm64 -0.107% -463,584 B -0.027%
Linux arm -0.055% -208,192 B -0.034%
Windows x86 -0.032% -300,650 B -0.018%
Wasm -0.633% -108,527 B -0.054%

Missing replay captures are excluded; Windows x86 has 0 baseline misses and 1,955 with the changed JIT.

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Nov 18, 2026
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 18, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@NinoFloris

This comment was marked as resolved.

@am11 am11 removed the arch-wasm WebAssembly architecture label Nov 24, 2026
@NinoFloris
NinoFloris force-pushed the jit/cse-store-local-temp branch from 67324c9 to 078c37d Compare November 29, 2026 18:32
@NinoFloris
NinoFloris marked this pull request as draft November 29, 2026 20:51
@NinoFloris
NinoFloris marked this pull request as ready for review November 29, 2026 20:51
Keep the destination store and its SSA name when a single CSE definition feeds a local. For a local with multiple definitions, walk backwards from each replacement use to verify that the same store reaches it on every path. Preserve constant propagation for reused locals and use a fresh temp when the destination must remain visible to an exception handler.
Recognize reused destinations as CSE temps and handle their propagation in assertion propagation and VN folding. When a local has multiple stores and can stay in a register, keep the read if the constant costs more to materialize. Allow propagation when it can eliminate the only store or avoid a stack load.
@NinoFloris
NinoFloris force-pushed the jit/cse-store-local-temp branch from f7f29f6 to 3e2c7aa Compare December 2, 2026 15:59

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants