Skip to content

JIT: STORE_LCL_FLD coalescing#126562

Merged
AndyAyersMS merged 11 commits intodotnet:mainfrom
AndyAyersMS:RefactorAtomicStoreCheck
Apr 27, 2026
Merged

JIT: STORE_LCL_FLD coalescing#126562
AndyAyersMS merged 11 commits intodotnet:mainfrom
AndyAyersMS:RefactorAtomicStoreCheck

Conversation

@AndyAyersMS
Copy link
Copy Markdown
Member

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.

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>
Copilot AI review requested due to automatic review settings April 5, 2026 15:46
@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 Apr 5, 2026
@AndyAyersMS
Copy link
Copy Markdown
Member Author

@EgorBo PTAL
fyi @dotnet/jit-contrib

Supersedes #126178

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) behind JitEnableStoreLclFldCoalescing.
  • 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).

Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp
Comment thread src/coreclr/jit/lower.cpp
@EgorBo
Copy link
Copy Markdown
Member

EgorBo commented Apr 7, 2026

I think we need to look at CI results before the next round of reviews

@AndyAyersMS AndyAyersMS closed this Apr 8, 2026
@AndyAyersMS
Copy link
Copy Markdown
Member Author

There are some related failures to investigate.

Copilot AI review requested due to automatic review settings April 10, 2026 14:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/jit/lower.cpp
@AndyAyersMS
Copy link
Copy Markdown
Member Author

@EgorBo take another look when you can

Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/coreclr/jit/lower.cpp Outdated
Copilot AI review requested due to automatic review settings April 18, 2026 14:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@AndyAyersMS
Copy link
Copy Markdown
Member Author

diffs

Looks like this has regressed some and is going to need more work.

Copilot AI review requested due to automatic review settings April 20, 2026 19:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/jit/lower.cpp Outdated
Comment thread src/tests/JIT/Directed/StructPromote/SpAddr.cs Outdated
AndyAyersMS and others added 2 commits April 25, 2026 08:08
- 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>
@AndyAyersMS AndyAyersMS merged commit 2a03681 into dotnet:main Apr 27, 2026
141 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants