Update the vector types to support having char as the element type#128116
Draft
tannergooding wants to merge 6 commits into
Draft
Update the vector types to support having char as the element type#128116tannergooding wants to merge 6 commits into
tannergooding wants to merge 6 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics |
Contributor
There was a problem hiding this comment.
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
charto supported scalar/vector type checks and introducesScalar<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
charappropriately (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. |
This was referenced May 13, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 normalizesShuffleto 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.