Skip to content

Conversation

@jkoritzinsky
Copy link
Member

@jkoritzinsky jkoritzinsky commented Dec 5, 2025

For Apple Mobile platforms, we need to slightly modify our policies for HW intrinsic support to provide the best user experience.

  1. We should set the baseline ISA to the ISA supported by the oldest hardware that supports an OS version you can build a .NET app against. For iOS, this is armv8-a (not armv8-a + lse as is currently specified)
  2. We do not want to support optimistic instruction sets by default. Methods with optimistic support can have their ReadyToRun code thrown out. As we cannot JIT, we'd prefer to use slightly less optimized ReadyToRun code than conditionally use better optimized ReadyToRun code or interpreted code depending on the device (with slower devices generally going down the slower interpreter path).
  3. The supported hardware intrinsics methods (which all have recursive implementations that will be considered mustExpand) will be rooted when CoreLib is in the R2R version bubble. This ensures that the JIT's fallback implementation will be available for the interpreter to use.
  4. For unsupported hardware intrinsics, the get_IsSupported method will be rooted so an explicit IsSupported => false implementation will be pregenerated. This ensures that we don't end up in a situation where any ISAs that are supported on the device but don't have any pre-jitted implementation for the given ISA are called by the interpreter.

To support newer intrinsics when targeting newer devices, the .NET Mac/iOS SDK should explicitly specify the new minimum instruction sets for the user's targeted OS version.

Fixes #122190

Contributes to #120047
Contributes to #120048

…s in case someone decides to use one that we don't generate R2R code for.
…o ensure we don't need to opportunistically jit all fallback implementations for every ISA.
Copy link
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 configures hardware intrinsic support for Apple Mobile platforms (iOS, tvOS, and their simulators) by adjusting instruction set baselines and handling platforms that cannot JIT. The changes ensure optimal ReadyToRun performance on these platforms while preventing fallback to the interpreter.

  • Sets the baseline ISA to armv8-a for iOS/tvOS platforms (down from armv8-a + lse)
  • Disables optimistic instruction sets by default for non-JIT platforms (iOS, tvOS, MacCatalyst simulators, and WebAssembly)
  • Roots hardware intrinsic methods and their IsSupported getters to ensure fallback implementations are available for the interpreter

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/tools/aot/crossgen2/Program.cs Adds logic to disable optimistic instruction sets for Apple Mobile platforms and conditionally roots hardware intrinsic methods when CoreLib is in the version bubble
src/coreclr/tools/aot/ILCompiler/Program.cs Updates parameter name from optimizingForSize to allowOptimistic for clarity
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj Registers the new ReadyToRunHardwareIntrinsicRootProvider compilation root provider
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunHardwareIntrinsicRootProvider.cs New root provider that roots all methods on supported hardware intrinsic types and IsSupported getters for unsupported types
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs Adds BubbleIncludesCoreModule property and TargetAllowsRuntimeCodeGeneration property to identify platforms that don't support JIT
src/coreclr/tools/Common/InstructionSetHelpers.cs Sets baseline ISA to armv8-a for iOS/tvOS, corrects x86-64 logic for OSX/MacCatalyst, and renames parameter to allowOptimistic

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-enable HardwareIntrinsics on Apple Mobile

2 participants