Skip to content

JIT: normalize loop-cloning offset ADD types - #133765

Merged
EgorBo merged 2 commits into
mainfrom
copilot/fix-ushort-limit-base-bug
Sep 14, 2026
Merged

EgorBo merged 2 commits into
mainfrom
copilot/fix-ushort-limit-base-bug

Conversation

Copilot AI commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Loop cloning emits an invalid ADD ushort for limits such as ushort n + 1000, triggering “Unexpected small type in IR.”

  • IR: Use genActualType(node) for the variable-offset ADD, preserving the local’s precise type.
  • Coverage: Extend OffsetLimit with the reported 65000 + 1000 case, ushort boundaries, and short arrays that must still throw.

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

Copilot AI changed the title [WIP] Fix loop cloning bug for ushort limit base JIT: normalize loop-cloning offset ADD types Sep 11, 2026
@EgorBo
EgorBo marked this pull request as ready for review September 11, 2026 23:59
Copilot AI lite review requested due to automatic review settings September 11, 2026 23:59
@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

All reviewed changes are covered by the final assessment and no blocking issues remain.

Pull request overview

Fixes invalid small-typed ADD nodes generated by loop cloning for ushort limits.

Changes:

  • Normalize variable-offset additions with genActualType.
  • Add ushort boundary and short-array regression coverage.
File summaries
File Description
src/tests/JIT/opt/Cloning/OffsetLimit.cs Adds ushort limits, boundary cases, and exception tests.
src/coreclr/jit/loopcloning.cpp Corrects the generated offset ADD type.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

@EgorBo
EgorBo requested a review from AndyAyersMS September 14, 2026 10:48
@EgorBo

EgorBo commented Sep 14, 2026

Copy link
Copy Markdown
Member

PTAL @AndyAyersMS missing genActualType, not sure if it could lead to real issues, but at least fixes the assert.

@EgorBo

EgorBo commented Sep 14, 2026

Copy link
Copy Markdown
Member

/ba-g knwon mono failures

@EgorBo
EgorBo enabled auto-merge (squash) September 14, 2026 23:35
@EgorBo
EgorBo merged commit 503b6ad into main Sep 14, 2026
138 of 141 checks passed
@EgorBo
EgorBo deleted the copilot/fix-ushort-limit-base-bug branch September 14, 2026 23:35
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 15, 2026
jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 18, 2026
<!-- -->
Loop cloning emits an invalid `ADD ushort` for limits such as `ushort n
+ 1000`, triggering “Unexpected small type in IR.”

- **IR:** Use `genActualType(node)` for the variable-offset `ADD`,
preserving the local’s precise type.
- **Coverage:** Extend `OffsetLimit` with the reported `65000 + 1000`
case, `ushort` boundaries, and short arrays that must still throw.

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

- Fixes dotnet#133761

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: EgorBo <[email protected]>
@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.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

JIT: (bug) Loop cloning builds a small-typed GT_ADD for a ushort limit base with a constant offset

4 participants