Skip to content

Remove 128-bit limit on Vector<T> size for ARM64#129852

Open
snickolls-arm wants to merge 1 commit into
dotnet:mainfrom
snickolls-arm:256-base
Open

Remove 128-bit limit on Vector<T> size for ARM64#129852
snickolls-arm wants to merge 1 commit into
dotnet:mainfrom
snickolls-arm:256-base

Conversation

@snickolls-arm

Copy link
Copy Markdown
Contributor

If InstructionSet_VectorT is available, set the class instance size to the process SVE vector length.

Increase the maximum bound in structMightRepresentSIMDType to allow the JIT to detect this when the ISA is present.

If InstructionSet_VectorT is available, set the class instance size to the
process SVE vector length.

Increase the maximum bound in structMightRepresentSIMDType to allow the JIT
to detect this when the ISA is present.
@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 25, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jun 25, 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.

#ifdef FEATURE_SIMD
return (structSize >= getMinVectorByteLength()) && (structSize <= getMaxVectorByteLength());
#ifdef TARGET_ARM64
const uint32_t max = compExactlyDependsOn(InstructionSet_VectorT) ? MAX_SVE_REGSIZE_BYTES : FP_REGSIZE_BYTES;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is going to potentially cause light up for a lot of unintended structs, which can hurt startup perf

Won't SVE, in most scenarios, rather be "size unknown" and in isolated scenarios a JIT (but not AOT or pre-JIT) environment may be able to explicitly query the true size and optimize a few things (like frame layout)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes agreed, we could query the actual size here in JIT mode, and use this as the upper bound. We can also filter sizes that are powers of 2 in bits, which could help with AOT as well.

As I've added the primitive for it, I could just do this in this PR.

Comment on lines +1222 to +1225
if (CPUCompileFlags.IsSet(InstructionSet_VectorT))
{
numInstanceFieldBytes = (uint32_t) GetSveLengthFromOS();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is "correct" because we'll rather have InstructionSet_VectorT128 if we have AdvSimd without SVE, correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking it's going to be InstructionSet_VectorT128 XOR InstructionSet_VectorT, never both enabled at the same time. So InstructionSet_VectorT is only serviced by SVE and will not be available when SVE is not there.

At some point we will need to decide if we prefer AdvSimd or SVE when the VL == 128 bits. This is dependent on micro-architecture, but we can find a different reason to pick one generally.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

never both enabled at the same time.

Correct, that should generally be an error scenario and effectively a bug in the ISA detection logic in the VM, but I wanted to make sure it was being persisted here and wasn't something "unique" for the scalable scenario.

At some point we will need to decide if we prefer AdvSimd or SVE when the VL == 128 bits. This is dependent on micro-architecture, but we can find a different reason to pick one generally.

👍

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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants