Skip to content

Update the vector types to support having char as the element type#128116

Draft
tannergooding wants to merge 6 commits into
dotnet:mainfrom
tannergooding:vector-char
Draft

Update the vector types to support having char as the element type#128116
tannergooding wants to merge 6 commits into
dotnet:mainfrom
tannergooding:vector-char

Conversation

@tannergooding
Copy link
Copy Markdown
Member

@tannergooding tannergooding commented May 13, 2026

This resolves #127611

It does some minimal cleanup of the type checks to centralize things where typeof(T) == typeof(char) checks had to be inserted. It also normalizes the ref files so that the generation works and normalizes Shuffle to use a helper so we don't need so much duplicated code for every type we need to support.

It does not go and cleanup up S.P.Corelib to directly use Vector128<char> and friends where relevant, I'm leaving that for a separate work item.

@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
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 extends the SIMD vector APIs and runtime support to treat char as a supported element type across Vector, Vector64/128/256/512, including new AsChar / Create(char) / shift / shuffle overloads, and updates the JIT/Mono pipelines to recognize char element types.

Changes:

  • Adds char to supported scalar/vector type checks and introduces Scalar<T> helpers to centralize type-category logic.
  • Introduces Vector*<char>-specific public APIs (create, shifts, shuffle, debug views) and ref-file updates to expose them.
  • Updates CoreCLR JIT and Mono SIMD handling to classify char appropriately (typically as a 16-bit unsigned element).

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/mono/mono/mini/simd-intrinsics.c Maps Vector128<char> element type to U2 for SIMD lowering/import.
src/mono/mono/mini/mini.h Expands “vector primitive” type check to include char.
src/mono/mono/mini/interp/transform-simd.c Normalizes interpreter SIMD element type char to U2.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64DebugView_1.cs Adds debugger CharView for Vector64<T>.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs Adds char APIs (As/Create/Shift/Shuffle) and refactors shuffle fallback logic.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64_1.cs Switches IsSupported logic to Scalar<T>.IsSupported.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512DebugView_1.cs Adds debugger CharView for Vector512<T>.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs Adds char APIs and refactors shuffle fallback logic.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512_1.cs Switches IsSupported logic to Scalar<T>.IsSupported.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256DebugView_1.cs Adds debugger CharView for Vector256<T>.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs Adds char APIs and refactors shuffle fallback logic.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256_1.cs Switches IsSupported logic to Scalar<T>.IsSupported.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128DebugView_1.cs Adds debugger CharView for Vector128<T>.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs Adds char APIs and refactors shuffle fallback logic (plus intrinsic paths).
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128_1.cs Switches IsSupported logic to Scalar<T>.IsSupported.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/SimdVectorExtensions.cs Removes unused usings (cleanup).
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Scalar.cs Centralizes scalar type traits and adds char arithmetic/bit ops support.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/ISimdVector_2.cs Removes unused using (cleanup).
src/libraries/System.Private.CoreLib/src/System/Numerics/VectorDebugView_1.cs Adds debugger CharView for Vector<T>.
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs Adds Vector<char> APIs (As/Shift) and uses Scalar<T> categorization.
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector_1.cs Makes Vector<T>.IsSupported rely on Scalar<T>.IsSupported.
src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs Updates public ref surface for Vector<char> APIs and normalizes ref formatting.
src/coreclr/vm/jitinterface.cpp Returns CORINFO_TYPE_CHAR for ELEMENT_TYPE_CHAR in numeric classification.
src/coreclr/tools/Common/TypeSystem/Common/TypeDesc.cs Treats char as primitive numeric for type system classification.
src/coreclr/jit/importercalls.cpp Allows SIMD base type char in intrinsic import/type checks.

Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Scalar.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs Outdated
Comment thread src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs Outdated
Copilot AI review requested due to automatic review settings May 13, 2026 14:19
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 31 out of 33 changed files in this pull request and generated 1 comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend the vector types to have char as a supported element type

2 participants