Skip to content

[API Proposal]: Arm64 SVE: Add LoadAndReplicateToVector for SVE #116006

Open

Description

@a74nh

Currently there is no obvious way to load a scalar and duplicate it across a vector in SVE. The closest we current have is something similar to:

Vector<uint> vec = Sve.DuplicateSelectedScalarToVector(Sve.LoadVectorNonFaulting(Sve.CreateTrueMaskUInt32(), input), 0);

This is not ideal as it has to load a full vector.

API suggestion:

/// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
public static unsafe Vector<T> LoadAndReplicateToVector(T* address, byte control); // ld1rb ld1rd ld1rh ld1rsb ld1rsh ld1rsw ld1rw

SVE does not have variants for float, double, long. I assume we can just use the unsigned versions.

Activity

  1. added
    untriaged
    on May 27, 2025
  2. dotnet-policy-service commented on May 27, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics
    See info in area-owners.md if you want to be subscribed.

  3. added
    arm-sve
    on May 27, 2025
  4. changed the title [-]Arm64 SVE: Add LoadAndReplicateToVector for SVE[/-] [+][API Proposal]: Arm64 SVE: Add LoadAndReplicateToVector for SVE[/+] on May 27, 2025
  5. added
    api-ready-for-review
    and removed
    untriaged
    on May 27, 2025
  6. added this to the Future milestone on May 30, 2025
  7. tannergooding commented on Jun 24, 2025

    @tannergooding
    Member

    @a74nh, I updated the proposal to match the existing convention which is LoadAndReplicateVector matching the AdvSimd signature + the offset control that is allowed for the SVE version.

    The DuplicateSelectedScalarToVector would be a different API that maps to the DUP instruction instead.

  8. bartonjs commented on Jun 24, 2025

    @bartonjs
    Member

    Video

    Looks good as proposed

    namespace System.Runtime.Intrinsics.Arm;
    
    public partial class Sve
    {
        // ld1rb ld1rd ld1rh ld1rsb ld1rsh ld1rsw ld1rw
        /// T: float, double, sbyte, short, int, long, byte, ushort, uint, ulong
        public static unsafe Vector<T> LoadAndReplicateToVector(T* address, byte control);
    }
  9. added
    api-approved
    and removed
    api-ready-for-review
    on Jun 24, 2025
  10. tcortega commented on Jan 14, 2026

    @tcortega
    Contributor

    Hey, I'd like to implement this API. I've been researching how SVE intrinsics work in the runtime and have a few questions before I start:

    I notice this API doesn't take a Vector<T> mask parameter like LoadVector128AndReplicateToVector does. Should the JIT generate an implicit PTRUE before the LD1R* instruction, similar to how other unpredicated SVE operations work (as seen in issue #114286)?

    Any specific patterns I should follow? I've been looking at PR #103392 as a reference.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedarea-System.Runtime.Intrinsicsarm-sve

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions