Skip to content

JIT: Preserve checked additions in rotation recognition - #133869

Merged
EgorBo merged 2 commits into
mainfrom
copilot/fix-rotation-recognition-issue
Sep 15, 2026
Merged

EgorBo merged 2 commits into
mainfrom
copilot/fix-rotation-recognition-issue

Conversation

Copilot AI commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Rotation recognition could discard a checked shift-count addition, suppressing OverflowException and leaving stale GTF_EXCEPT flags that trigger a Checked-JIT assertion.

  • Recognition: Require !gtOverflow() before folding ADD(NEG(y), N) into a rotate.
  • Regression coverage: Add 14 cases covering 32/64-bit left/right rotations, overflow boundaries, unchecked negation wrapping, and normal shift counts.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 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: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix rotation recognition dropping OverflowException in add.ovf JIT: Preserve checked additions in rotation recognition Sep 14, 2026
Copilot AI requested a review from EgorBo September 14, 2026 13:36
@EgorBo
EgorBo marked this pull request as ready for review September 14, 2026 13:47
Copilot AI lite review requested due to automatic review settings September 14, 2026 13:47
@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.

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 review issues remain.

Pull request overview

Preserves checked shift-count additions during JIT rotation recognition and adds regression coverage.

Changes:

  • Skip rotation folding when the addition may overflow.
  • Add 14 32/64-bit rotation regression cases.
File summaries
File Summary
src/coreclr/jit/morph.cpp Guards rotation recognition against checked additions.
src/tests/JIT/CodeGenBringUpTests/Rotate.cs Adds checked rotation regression tests.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

@jkoritzinsky jkoritzinsky added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-Infrastructure labels Sep 15, 2026
@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.

@EgorBo

EgorBo commented Sep 15, 2026

Copy link
Copy Markdown
Member

PTAL @jakobbotsch @dotnet/jit-contrib, copilot added probably way more tests than it needed, but it won't hurt I think

@EgorBo
EgorBo requested a review from jakobbotsch September 15, 2026 12:13
@EgorBo

EgorBo commented Sep 15, 2026

Copy link
Copy Markdown
Member

/ba-g #133936

@EgorBo
EgorBo enabled auto-merge (squash) September 15, 2026 15:08
@EgorBo
EgorBo merged commit 373fa42 into main Sep 15, 2026
145 of 150 checks passed
@EgorBo
EgorBo deleted the copilot/fix-rotation-recognition-issue branch September 15, 2026 15:09
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 16, 2026
jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 18, 2026
<!-- -->
Rotation recognition could discard a checked shift-count addition,
suppressing `OverflowException` and leaving stale `GTF_EXCEPT` flags
that trigger a Checked-JIT assertion.

- **Recognition:** Require `!gtOverflow()` before folding `ADD(NEG(y),
N)` into a rotate.
- **Regression coverage:** Add 14 cases covering 32/64-bit left/right
rotations, overflow boundaries, unchecked negation wrapping, and normal
shift counts.

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes dotnet#133863

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
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

Status: Done

Development

Successfully merging this pull request may close these issues.

JIT: (bug) Rotation recognition drops a checked add.ovf in the shift count (missing OverflowException + Checked assert)

6 participants