Repository navigation
JIT: avoid repeated compaction of shared targets - #136976
Conversation
Prefer removing an empty predecessor when it needs fewer edge redirects. Fixes dotnet#136968 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change to prefer lower-cost empty-predecessor removal in JIT flow-graph optimization.
No open issues 🎉
What changed in this PR
This PR reduces repeated work in the JIT’s flow-graph optimization by preferring removal of an empty predecessor over compaction of its shared target when removal requires fewer edge redirects.
Changes:
- Compares incoming-edge counts to select the cheaper transformation.
- Uses existing empty-block removal checks and falls back to compaction when removal is disallowed or unsuccessful.
- Marks the flow graph as changed after successful removal.
| File | Description |
|---|---|
src/coreclr/jit/fgopt.cpp |
Adds a cost-based preference for empty-predecessor removal before shared-target compaction. |
Review effort: Balanced
filipnavara
left a comment
There was a problem hiding this comment.
Checked on my original use case. Drops the compile time for the Kiota method from 35s to 1.5s on a checked JIT. The byte output is identical.
|
@jakobbotsch ptal |
|
Have an IL offset assert I need to sort out. |
Keep ranges ordered when optimization moves an await outside the recorded range. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Needed to adjust the IL offsets in async to avoid the assert. |
Ignore invalid await locations and keep split ranges adjacent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Prefer removing an empty predecessor when it needs fewer edge redirects than compacting its shared target. Keep the existing compaction path when removal is not legal. This avoids repeatedly moving a high-fan-in target and its predecessor list.
Windows x64 crossgen2, using the issue's string-to-int
Factory.Maprepro with full optimization. Median per-method JIT time over two runs:Baseline and patched R2R images are byte-identical at all four sizes. All switch arms, default, and null passed execution without JIT fallback.
Windows x64 Release/Checked JIT builds and jit-format passed.
Regression_ro_2passed both normally and withJitStress=2: 492 passed, 0 failed, 7 existing skips per run.A CoreLib/Linq/Json compilation comparison covered 41,455 methods. 69 methods changed native code size, with a net increase of 13 bytes; this is not generally codegen-neutral.
Resolves #136968
Note
This PR was prepared with GitHub Copilot.