Skip to content

Enable must-throw for unsupported intrinsics under optimizations#129007

Draft
tannergooding wants to merge 9 commits into
dotnet:mainfrom
tannergooding:copilot/update-impsupportednamedintrinsic
Draft

Enable must-throw for unsupported intrinsics under optimizations#129007
tannergooding wants to merge 9 commits into
dotnet:mainfrom
tannergooding:copilot/update-impsupportednamedintrinsic

Conversation

@tannergooding
Copy link
Copy Markdown
Member

@tannergooding tannergooding commented Jun 4, 2026

This should put less pressure on the doing repetitive work and should allow merging of the various must throw blocks. The general issue was noticed in #128513 (comment), where we had some size regressions due to cold blocks for throwing intrinsics not being merged as they callee was unique for each; even though we don't really care about it being in the stack trace (its optimized code, inlining and loss of that stack trace entry was already possible).

Copilot AI and others added 5 commits June 4, 2026 17:50
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
…4/128/256/512 ISAs in lookupId

Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 4, 2026 18:55
@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 Jun 4, 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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts CoreCLR JIT intrinsic recognition so that unsupported intrinsics are handled more consistently under optimizations: cross-platform intrinsic APIs (with managed fallbacks) no longer hard-throw PlatformNotSupportedException when the ISA isn’t available, while platform-specific intrinsic APIs (and platform-mismatched sub-namespaces) are forced to throw. It also changes unsupported-intrinsic expansion to prefer emitting a MustThrowException in optimized codegen, avoiding a redundant managed call that would only throw anyway.

Changes:

  • Extend HWIntrinsicInfo::lookupId with an isXplatIntrinsic flag to distinguish cross-platform intrinsics (managed fallback) from platform-specific intrinsics (must throw PNSE when unsupported).
  • In lookupNamedIntrinsic, correctly classify intrinsics under System.Runtime.Intrinsics including platform-mismatched sub-namespaces (e.g., .X86 on ARM64) as must-throw PNSE.
  • In impUnsupportedNamedIntrinsic, return a MustThrowException node not only for mustExpand, but also when optimizations are enabled.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/importercalls.cpp Classifies cross-platform vs platform-specific intrinsics and forces PNSE for platform-mismatched intrinsic namespaces; enables must-throw emission under optimizations for unsupported intrinsics.
src/coreclr/jit/hwintrinsic.h Updates HWIntrinsicInfo::lookupId declaration to accept the new isXplatIntrinsic parameter.
src/coreclr/jit/hwintrinsic.cpp Implements the new isXplatIntrinsic behavior: cross-platform intrinsics with unsupported ISA return NI_Illegal (allowing managed fallback), platform-specific intrinsics return PNSE.

Copilot AI review requested due to automatic review settings June 4, 2026 23:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/jit/hwintrinsic.cpp Outdated
Comment thread src/coreclr/jit/importercalls.cpp Outdated
Copilot AI review requested due to automatic review settings June 5, 2026 01:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/jit/importercalls.cpp Outdated
Comment thread src/coreclr/jit/importercalls.cpp
@tannergooding tannergooding force-pushed the copilot/update-impsupportednamedintrinsic branch from 2e60a4b to ad543ec Compare June 5, 2026 02:57
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.

3 participants