JIT: STORE_LCL_FLD coalescing#126562
Merged
Merged
Conversation
Refactor the lowering-time store coalescing machinery so adjacent constant GT_STORE_LCL_FLD writes can reuse the existing combine logic that was previously limited to STOREIND/STORE_BLK. Gate the new local-field path from LowerStoreLocCommon with JitEnableStoreLclFldCoalescing. Extend the struct-promotion regression coverage for the newly handled cases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
Author
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the JIT lowering-time store coalescing logic to extend existing adjacent-constant-store combining (previously focused on indirections) to also handle adjacent GT_STORE_LCL_FLD writes, guarded by a new JIT config switch, and adds regression coverage for struct-promotion-related cases.
Changes:
- Extend store coalescing to support
GT_STORE_LCL_FLD(including some overlapping-store scenarios) behindJitEnableStoreLclFldCoalescing. - Refactor coalescing machinery to share logic across store kinds and centralize atomicity checks.
- Add JIT regression tests covering non-address-exposed, address-exposed, and overlapping local-field store patterns.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tests/JIT/Directed/StructPromote/SpAddr.cs | Adds new regression scenarios for local-field store coalescing, including overlap and address-exposed cases. |
| src/coreclr/jit/lower.h | Extends coalescing data structure and declares new shared coalescing/atomicity helpers. |
| src/coreclr/jit/lower.cpp | Implements shared coalescing path for STORE_LCL_FLD and refactors existing store-indir coalescing to reuse it. |
| src/coreclr/jit/jitconfigvalues.h | Adds JitEnableStoreLclFldCoalescing release config gate (default enabled). |
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
reviewed
Apr 7, 2026
kg
approved these changes
Apr 7, 2026
EgorBo
reviewed
Apr 7, 2026
EgorBo
reviewed
Apr 7, 2026
EgorBo
reviewed
Apr 7, 2026
EgorBo
reviewed
Apr 7, 2026
Member
|
I think we need to look at CI results before the next round of reviews |
Member
Author
|
@EgorBo take another look when you can |
This was referenced Apr 10, 2026
Open
EgorBo
approved these changes
Apr 13, 2026
Member
Author
|
Looks like this has regressed some and is going to need more work. |
- LowerCheckCoalescedStoreAtomicity: also require compRetBuffArg != BAD_VAR_NUM before relaxing atomicity for retbuf stores. Previously, when no retbuf was present, both lclNum and compRetBuffArg defaulted to BAD_VAR_NUM and the comparison trivially held, allowing non-atomic coalescing for unrelated indirect stores. - SpAddr regression test: compute the expected `overlapping` value based on BitConverter.IsLittleEndian so the test does not rely on little-endian byte layout. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Refactor the lowering-time store coalescing machinery so adjacent constant GT_STORE_LCL_FLD writes can reuse the existing combine logic that was previously limited to STOREIND/STORE_BLK. Gate the new local-field path from LowerStoreLocCommon with JitEnableStoreLclFldCoalescing. Extend the struct-promotion regression coverage for the newly handled cases.