Skip to content

JIT: fix range assertions for bypassed phi blocks - #133268

Merged
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:fix-133267-phi-range-assertions
Sep 7, 2026
Merged

JIT: fix range assertions for bypassed phi blocks#133268
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:fix-133267-phi-range-assertions

Conversation

@EgorBo

@EgorBo EgorBo commented Sep 4, 2026

Copy link
Copy Markdown
Member

Fixes #133267. Avoid stale phi-block assertions after jump threading.

Copilot-generated.

Fixes dotnet#133267.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 56f763ef-1e54-421c-9e79-fe14ed2b906a
Copilot AI lite review requested due to automatic review settings September 4, 2026 22:10
@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.

@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 4, 2026

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.

🔵 Needs a closer look

It changes JIT range/assertion-merging behavior (compiler correctness surface area), and I did not validate it with local builds/tests in this review.

Pull request overview

This PR updates JIT range-check analysis to avoid relying on potentially stale assertion sets after flow edits (e.g., jump threading bypassing phi-related blocks), and adds a targeted regression test for the reported miscompile scenario.

Changes:

  • Adjust range computation for locals so assertion merging happens at the use site (via MergeAssertion) rather than inside ComputeRangeForLocalDef.
  • Update ComputeRangeForLocalDef signature to no longer take the use block.
  • Add a new JitBlue regression test (Runtime_133267) and register it in Regression_ro_2.csproj.
File summaries
File Description
src/coreclr/jit/rangecheck.h Updates ComputeRangeForLocalDef declaration to drop the BasicBlock* parameter.
src/coreclr/jit/rangecheck.cpp Moves assertion merging responsibility to the local-use path (MergeAssertion) to avoid stale phi-block assertion inputs.
src/tests/JIT/Regression/JitBlue/Runtime_133267/Runtime_133267.cs Adds a regression test that fails if the JIT incorrectly throws ArgumentException under optimization.
src/tests/JIT/Regression/Regression_ro_2.csproj Registers the new regression test for compilation/execution in the ro_2 suite.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 7, 2026 11:07

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.

🟡 Changes recommended

The new MergeAssertion call for locals can introduce redundant assertion merging at existing call sites, potentially impacting JIT compilation performance.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/coreclr/jit/rangecheck.cpp
@EgorBo

EgorBo commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

PTAL @jakobbotsch @dotnet/jit-contrib

A small correctness issue found by AI. Not too many diffs so it's fine to remove that "improve range by assertions" logic.

@EgorBo
EgorBo requested a review from jakobbotsch September 7, 2026 15:30

@jakobbotsch jakobbotsch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I guess it doesn't apply here since this just removes the opt, but it would be nice to keep track of these places if we find more so that we know what to do if we ever get around to fixing the SSA update story. Perhaps some // TODO-SSAUPDATING: Remove this

@EgorBo

EgorBo commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

/ba-g unrelated swiftc error in monointerp

@EgorBo
EgorBo merged commit b22e1b8 into dotnet:main Sep 7, 2026
138 of 142 checks passed
@EgorBo
EgorBo deleted the fix-133267-phi-range-assertions branch September 7, 2026 18:40
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.

Unexpected ArgumentException in Tier1 vs Tier0

3 participants