Skip to content

Conversation

@a74nh
Copy link
Contributor

@a74nh a74nh commented Sep 4, 2025

Enables all standard arithmetic operations.
Does not include compare operations.

Enables all standard arithmetic operations.
Does not include compare operations.
@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 Sep 4, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 4, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@a74nh
Copy link
Contributor Author

a74nh commented Sep 4, 2025

I plan on putting compares in a later PR as there is some extra debugging I need to do first.
Fuzzlyn looks clean over 3000 seconds.
A few small improvements with spmidiff. Although we weren't expecting much there as most of the current SVE tests/usage is not using constants.

@a74nh a74nh marked this pull request as ready for review September 5, 2025 09:28
@a74nh
Copy link
Contributor Author

a74nh commented Sep 5, 2025

@tannergooding @EgorBo : I'm happy with this now

@JulieLeeMSFT JulieLeeMSFT added the arm-sve Work related to arm64 SVE/SVE2 support label Sep 29, 2025
@JulieLeeMSFT
Copy link
Member

We will review .NET 11 PRs when we are done with .NET 10 last minute works and less busy.
CC @dotnet/arm64-contrib.

@steveisok steveisok added this to the 11.0.0 milestone Oct 6, 2025
@SwapnilGaikwad
Copy link
Contributor

Hi @EgorBo , this PR slipped through our radar. Could you take a look at it, please?

@JulieLeeMSFT
Copy link
Member

@EgorBo, PTAL.

@EgorBo EgorBo self-requested a review December 3, 2025 13:26
Copy link
Member

@EgorBo EgorBo left a comment

Choose a reason for hiding this comment

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

Sorry for the delayed response, LGTM, let's run Fuzzlyn on this

Copilot AI review requested due to automatic review settings December 3, 2025 13:28
@EgorBo
Copy link
Member

EgorBo commented Dec 3, 2025

/azp run Fuzzlyn

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copilot finished reviewing on behalf of EgorBo December 3, 2025 13:32
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

This PR enables ARM64 SVE (Scalable Vector Extension) nodes to be treated as generic operations, allowing all standard arithmetic operations to be processed through the common value numbering and optimization paths. The changes align SVE intrinsics with existing AdvSimd intrinsics by mapping them to generic tree operations.

Key Changes

  • Added mappings for 13 SVE intrinsics (And, Or, Xor, Not, BitwiseClear, Add, Subtract, Multiply, Divide, Negate, ShiftLeftLogical, ShiftRightArithmetic, ShiftRightLogical) to their corresponding generic tree operations
  • Relaxed GT_AND_NOT assertions to allow this operation before lowering on ARM64 (needed for SVE BitwiseClear)
  • Added ARM64-specific shift handling for "wide elements" variants using a new NarrowSimdLong template function
  • Restructured conditional compilation to check for shift operations before platform-specific code paths

Reviewed changes

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

File Description
src/coreclr/jit/gentree.cpp Added SVE intrinsic to generic operation mappings and ARM64 shift narrowing logic; moved GT_AND_NOT assertion to be XARCH-specific
src/coreclr/jit/valuenum.cpp Added ARM64 shift narrowing in value numbering; relaxed GT_AND_NOT assertions across three evaluation functions; restructured shift handling to be checked before platform-specific conditionals
src/coreclr/jit/simd.h Added NarrowSimdLong template functions to handle narrowing of uint64_t vector elements to smaller types during shift operations

a74nh and others added 3 commits December 4, 2025 14:02
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tannergooding
Copy link
Member

This looks like it might be missing some handling in gentree.cpp and lowerarmarch.cpp so that the transform of GT_AND(x, GT_NOT(y)) back into NI_Sve_BitwiseClear(x, y) can occur.

In particular, looks like we have a lack of handling in GetHWIntrinsicIdForBinOp and LowerHWIntrinsic where there is AdvSimd handling already. -- That is, we got NODE_ID -> GT_OP already, but the PR lacks support for the other direction: GT_OP -> NODE_ID

It's possible there is "more" work to be done here too, so that all the end to end transforms can light up, but that should be the bulk of it.

auto-merge was automatically disabled December 5, 2025 14:54

Head branch was pushed to by a user without write access

@a74nh
Copy link
Contributor Author

a74nh commented Dec 5, 2025

This looks like it might be missing some handling in gentree.cpp and lowerarmarch.cpp so that the transform of GT_AND(x, GT_NOT(y)) back into NI_Sve_BitwiseClear(x, y) can occur.

In particular, looks like we have a lack of handling in GetHWIntrinsicIdForBinOp and LowerHWIntrinsic where there is AdvSimd handling already. -- That is, we got NODE_ID -> GT_OP already, but the PR lacks support for the other direction: GT_OP -> NODE_ID

It's possible there is "more" work to be done here too, so that all the end to end transforms can light up, but that should be the bulk of it.

What is happening right now is that it ends up with a NI_AdvSimd_Arm64_BitwiseClear` node:

  • In impSpecialIntrinsic(), it uses gtNewSimdUnOpNode(GT_NOT...) and gtNewSimdBinOpNode(GT_AND....). Both of these will return an NI_AdvSimd_Arm64_... instrinsic.
  • In LowerHWIntrinsic() because it's looking for GT_AND/GT_NOT there is no way to tell this is SVE specific.

In both cases, because the size is SIMD_16, I don't think it really matter that it creates a NEON node. And I think that forcing it to SVE would be quite messy, as there's no obvious check you can make for SVE in those cases (especially during lowering)

Once SVE is variable then yes we will need SVE nodes. I've added a few asserts on the sizes so that these are caught later down the line. Alternatively, we could pause this to post variable length SVE.

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 arm-sve Work related to arm64 SVE/SVE2 support 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