JIT: Coalesce adjacent constant-address stores#130107
Merged
Merged
Conversation
Extend LowerStoreCoalescing to recognize STOREIND nodes whose address is an absolute (non-relocatable) constant, such as writes to adjacent fields of a non-GC static struct. The constant address is treated as the offset from a common null base so adjacent stores can be merged into a single wider store. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Member
Author
|
@MihuBot -nuget |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends JIT lowering-time store coalescing so that adjacent STOREIND nodes whose address is a non-relocatable absolute constant can be recognized as targeting the same “base” and then merged into a single wider store, while updating offset-related arithmetic/alignment checks to support that new address form.
Changes:
- Teach
GetLoadStoreCoalescingDatato treat non-relocatable constant addresses as(base=null, offset=<absolute address>)so adjacent constant-address stores can be matched/coalesced. - Widen
LoadStoreCoalescingData::offsettossize_tand adjust related offset math, alignment, and atomicity checks to account forbaseAddr == nullptr. - Update the store-coalescing rewrite path to correctly update either
GT_LEAoffsets or constant-addressGT_CNS_INTvalues after coalescing.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/lower.h | Widen store-coalescing offset storage to ssize_t. |
| src/coreclr/jit/lower.cpp | Add constant-address handling for coalescing + adjust atomicity/alignment and rewrite logic accordingly. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
JulieLeeMSFT
reviewed
Jul 2, 2026
Member
Author
|
PTAL @AndyAyersMS as someone who recently touched this area, cc @dotnet/jit-contrib |
AndyAyersMS
approved these changes
Jul 7, 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.
Extend
LowerStoreCoalescingto recognizeSTOREINDnodes whose address is an absolute (non-relocatable) constant, e.g. writes to adjacent fields of a non-GC static struct:Codegen for
Teston win-x64:Diffs
Basically, I represent it as baseAddr being null and offset being the full absolute address, the rest of the code is the same, just had to bump the type of offset from int to ssize_t