JIT: STORE_LCL_FLD coalescing#126562
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>
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
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). |
|
I think we need to look at CI results before the next round of reviews |
|
There are some related failures to investigate. |
|
@EgorBo take another look when you can |
|
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>
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.