Skip to content

JIT: Preserve exceptions during jump threading - #134279

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-133982-preserve-jump-thread-exceptions
Sep 21, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix-133982-preserve-jump-thread-exceptions

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Summary

  • preserve exceptions when threading a redundant branch
  • require the dominating comparison to cover the removed exception set
  • add regression coverage for the lost DivideByZeroException

Testing

  • Windows x64 Checked JIT build
  • RedundantBranchDominating: 7 tests passed
  • standalone repro throws DivideByZeroException
  • SuperPMI: 42 of 2,801,860 contexts changed, totaling +308 bytes

Resolves #133982

Note

This pull request description was generated with GitHub Copilot.

Jump threading could bypass exceptions from a redundant comparison.
Require the dominating comparison to cover the removed exception set.

Fixes dotnet#133982

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2f9acea8-450d-4bad-8278-b5a324b6f655
Copilot AI lite review requested due to automatic review settings September 19, 2026 16:08
@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 Sep 19, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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

@AndyAyersMS
AndyAyersMS requested a review from EgorBo September 19, 2026 16:09
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@EgorBo PTAL
fyi @dotnet/jit-contrib

minimal (~40) spmi diffs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The narrowly scoped guard matches the existing exception-set contract and the regression test directly covers the lost exception.

Review effort: Lite
Findings: None

What changed in this PR

Fixes RyuJIT jump threading so exception-producing comparisons are not incorrectly removed.

Changes:

  • Validates dominating and dominated exception sets before threading.
  • Adds a DivideByZeroException regression test.
File Description
src/​coreclr/​jit/​redundantbranchopts.cpp Preserves uncovered exceptions during jump threading.
src/​coreclr/​jit/​compiler.h Updates the helper signature.
src/​tests/​JIT/​opt/​RedundantBranch/​RedundantBranchDominating.cs Adds regression coverage.

@AndyAyersMS
AndyAyersMS merged commit 9351053 into dotnet:main Sep 21, 2026
142 of 145 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 22, 2026
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.

JIT: (bug) dominator-based jump threading in redundantbranchopts drops a mandatory DivideByZeroException

3 participants