SVE: truncate Extract results for small types#125172
Merged
jakobbotsch merged 4 commits intodotnet:mainfrom Mar 5, 2026
Merged
SVE: truncate Extract results for small types#125172jakobbotsch merged 4 commits intodotnet:mainfrom
jakobbotsch merged 4 commits intodotnet:mainfrom
Conversation
The clast and last instructions return 32bit or 64bit values, whereas the C# API allows for byte and short return values. Fixes dotnet#125058
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
jakobbotsch
reviewed
Mar 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ARM64 SVE scalar extract intrinsics (clasta/clastb and lasta/lastb) to ensure results are correctly sign/zero-extended for small integral return types (byte/sbyte/short/ushort), matching the C# API expectations and preventing miscompilations like #125058.
Changes:
- Adjust SVE scalar codegen to use 32/64-bit emit sizes and explicitly extend results for small integral base types.
- Simplify SVE scalar intrinsic import by removing an auxiliary JIT type assignment for the conditional extract scalar variant.
- Add a new JIT regression test covering
Sve.ConditionalExtractAfterLastActiveElementreturningshort.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/jit/hwintrinsiccodegenarm64.cpp | Ensures scalar clast*/last* results are properly extended for small integral types and uses correct 4/8-byte emission sizes. |
| src/coreclr/jit/hwintrinsicarm64.cpp | Removes auxiliary type propagation for the conditional extract scalar import path. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Adds the new regression test source file to the compilation list. |
| src/tests/JIT/Regression/JitBlue/Runtime_125058/Runtime_125058.cs | New regression reproducer asserting correct behavior under SVE support. |
Comments suppressed due to low confidence (2)
src/coreclr/jit/hwintrinsiccodegenarm64.cpp:2741
- The comment mentions only "byte/short" base types, but the code uses
varTypeIsSmall(intrin.baseType)which also includessbyte/ushort. Please adjust the wording to reflect that this applies to all 8- and 16-bit integral base types (signed and unsigned).
// clasta/clastb scalar variants produce 32-bit results for byte/short base types.
// Narrow down to the correct type if required.
if (varTypeIsSmall(intrin.baseType))
{
src/coreclr/jit/hwintrinsiccodegenarm64.cpp:2783
- This comment says "byte/short" but the guard is
varTypeIsSmall(intrin.baseType), which coverssbyte/ushortas well. Please update the wording to describe all small (8/16-bit) integral base types so the comment matches the behavior.
// lasta/lastb scalar variants produce 32-bit results for byte/short base types.
// Narrow down to the correct type if required.
if (varTypeIsSmall(intrin.baseType))
{
This was referenced Mar 4, 2026
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.
The clast and last instructions return 32bit or 64bit values, whereas the C# API allows for byte and short return values.
Fixes #125058