Skip to content

JIT: stop inferring through bitwise complement - #133700

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/jit-complemented-relop-inference
Sep 11, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/jit-complemented-relop-inference

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

Summary

  • stop redundant branch inference from treating bitwise GT_NOT as logical negation
  • add coverage for complemented comparison results with equal and unequal operands

Fixes #133557.

Validation

  • python src\coreclr\scripts\jitformat.py -r . -o windows -a x64
  • build.cmd clr.jit -rc Checked
  • RedundantBranchSimplify.TestComplementedRelop: failed before the fix and passed afterward
  • all 31 RedundantBranchSimplify tests passed
  • SuperPMI asmdiffs: no diffs across 987,555 successfully compiled Windows x64 contexts in 9 collections; 0 failing and 912 missing contexts

Regression history

The underlying issue was introduced by #69291 and first shipped in .NET 7. Optimized IL reproduces on .NET 7 through .NET 11; the exact unoptimized IL shape from #133557 is newly exposed on current main.

Note

This PR description was generated with GitHub Copilot CLI.

Remove the unsound treatment of GT_NOT as logical negation in redundant branch inference. This fixes dotnet#133557.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: ebb6b542-7cf8-4035-9148-82c31a248fa3
Copilot AI lite review requested due to automatic review settings September 11, 2026 14:36
@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 11, 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 11, 2026 14:39
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@EgorBo PTAL
fyi @dotnet/jit-contrib

I fixed this in VN a while back, but missed that it was still in RBO.

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.

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

This PR fixes unsound JIT inference through bitwise complement and adds regression coverage.

Changes:

  • Restricts compound predicate inference to GT_AND and GT_OR.
  • Adds equal/unequal complemented-comparison tests.
File summaries
File Description
src/tests/JIT/opt/RedundantBranch/RedundantBranchSimplify.cs Adds regression coverage.
src/coreclr/jit/redundantbranchopts.cpp Removes invalid GT_NOT inference.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

@AndyAyersMS

Copy link
Copy Markdown
Member Author

Failures are #133702

@AndyAyersMS

Copy link
Copy Markdown
Member Author

/ba-g known mono test failures, plus build timeouts

@AndyAyersMS

Copy link
Copy Markdown
Member Author

no diffs

@AndyAyersMS
AndyAyersMS merged commit 9954529 into dotnet:main Sep 11, 2026
141 of 144 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 14, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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) a branch on the bitwise complement of a comparison makes a later identical comparison fold to the wrong value

3 participants