Skip to content

Conversation

tannergooding
Copy link
Member

This resolves #117569

@bollhals
Copy link
Contributor

If you don't mind me asking, for my education:
Why does a change like that require changes in jit?
Would it have regressed code gen due not inlining them properly or is it to reduce the work the jit has to do or something else?

@tannergooding
Copy link
Member Author

Why does a change like that require changes in jit?

The JIT work isn't strictly required and in most cases you'll get the expected codegen.

However, there is still some impact to JIT throughput and general inlining budget which can be optimized by special-casing these "core helpers". So rather than having to go through the recognize method call->scan IL of callee->compute profitability->check against budget->inline il (if within budget)->potentially other opts/transforms->constant we can just do recognize method call->constant.

Since these types are "perf critical" and the logic to support them in the JIT is relatively trivial, we do so to ensure it provides that minimally better experience.

@bollhals
Copy link
Contributor

Thanks for the explanation 👍🏼, very much appreciated.

@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Jul 23, 2025
@tannergooding tannergooding marked this pull request as ready for review August 3, 2025 13:33
@Copilot Copilot AI review requested due to automatic review settings August 3, 2025 13:33
Copy link
Contributor

@Copilot 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 adds vector constant property extensions that are only available for certain element types (T). These extensions provide convenient access to common mathematical and special values like One, Zero, NaN, Pi, E, Tau, NegativeZero, NegativeInfinity, etc. as vector constants with all lanes populated with the same value.

Key changes:

  • Adds extension properties for Vector64<T>, Vector128<T>, Vector256<T>, Vector512<T>, and Vector<T> types
  • Properties are constrained by generic constraints (e.g., IFloatingPointConstants<T>, IFloatingPointIeee754<T>, ISignedNumber<T>)
  • Updates test files to use the new properties instead of Vector.Create() calls

Reviewed Changes

Copilot reviewed 55 out of 57 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs Adds API surface definitions for the new extension properties
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector*.cs Implements the extension properties for all vector types
src/coreclr/jit/hwintrinsic*.cpp Adds JIT intrinsic handling for the new properties
src/coreclr/jit/hwintrinsiclist*.h Registers the new intrinsic identifiers
Various test files Updates existing tests to use new property syntax instead of Vector.Create()

@tannergooding tannergooding merged commit 80c8bb7 into dotnet:main Aug 20, 2025
161 of 163 checks passed
@tannergooding tannergooding deleted the fix-117569 branch August 20, 2025 22:00
@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose floating-point constants for generic Vector types using extension properties
9 participants