Skip to content

Implement SVE2 Counting APIs#122602

Merged
tannergooding merged 5 commits intodotnet:mainfrom
ylpoonlg:github-sve2_counting
Mar 9, 2026
Merged

Implement SVE2 Counting APIs#122602
tannergooding merged 5 commits intodotnet:mainfrom
ylpoonlg:github-sve2_counting

Conversation

@ylpoonlg
Copy link
Contributor

Contributes to #94017

  • Add CountMatchingElements and CountMatchingElementsIn128BitSegments.

  • Fix SveTernOpMaskedOpTestTemplate to handle different return types. It was previously assuming Op1BaseType == RetBaseType, now it is relaxed to sizeof(Op1BaseType) == sizeof(RetBaseType) since their masks/predicates are the same.

@dotnet/arm64-contrib @a74nh

* Add `CountMatchingElements` and `CountMatchingElementsIn128BitSegments`.

* Fix SveTernOpMaskedOpTestTemplate to handle different return types.
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Dec 17, 2025
@dotnet-policy-service
Copy link
Contributor

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

Fix HWIntrinsicTests conflicts.
Copy link
Contributor

@dhartglassMSFT dhartglassMSFT left a comment

Choose a reason for hiding this comment

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

Looked at the code under jit/*, lgtm

@jeffhandley
Copy link
Member

@tannergooding Ensuring this is in your PR review queue

Copy link
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

Adds the new Arm64 SVE2 “counting” intrinsics proposed in #94017 (CountMatchingElements / CountMatchingElementsIn128BitSegments) and wires them through the JIT intrinsic list and test generation, including updating the masked-ternary test template to support differing (but same-sized) operand/return element types.

Changes:

  • Added Sve2.Arm64.CountMatchingElements and Sve2.Arm64.CountMatchingElementsIn128BitSegments overloads (plus PlatformNotSupported + ref surface area).
  • Added CoreCLR JIT intrinsic definitions for HISTCNT and HISTSEG.
  • Added/updated JIT HWIntrinsic tests and test helpers for the new APIs and for mixed signed/unsigned return types.

Reviewed changes

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

Show a summary per file
File Description
src/tests/JIT/HardwareIntrinsics/Arm/Shared/_SveTernOpMaskedOpTestTemplate.template Updates masked ternary op test template to allow differing return type size-equivalence and adjusts mask/false value handling.
src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs Adds managed “golden” helper implementations for the new counting intrinsics.
src/tests/Common/GenerateHWIntrinsicTests/Arm/Sve2Tests.cs Registers generated test cases for the new SVE2 counting intrinsics.
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs Adds the public API surface area for the new SVE2 counting methods.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve2.cs Adds the intrinsic method declarations for supported platforms.
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve2.PlatformNotSupported.cs Adds PlatformNotSupported stubs for the new methods.
src/coreclr/jit/hwintrinsiclistarm64sve.h Adds the CoreCLR intrinsic mappings for HISTCNT/HISTSEG.

@jeffhandley
Copy link
Member

@tannergooding This PR is ready for your review

@tannergooding
Copy link
Member

/ba-g unrelated http timeout

@tannergooding tannergooding merged commit 1b78ef7 into dotnet:main Mar 9, 2026
172 of 174 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime.Intrinsics 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.

6 participants