Skip to content

Commit

Permalink
Implement various other simple vector APIs from 93513 (dotnet#103837)
Browse files Browse the repository at this point in the history
* Update Vector<T> to implement ISimdVector<TSelf, T>

* Expose various constants for Vector2/3/4

* Expose Exp, Log, and Log2 on the other vector types

* Expose CopySign on the vector types

* Expose DegreesToRadians and RadiansToDegrees on the vector types

* Expose Hypot on the vector types

* Expose Lerp on the vector types

* Expose Truncate and Round on the vector types

* Cleanup some of the implementations to use helper functions where possible

* Expose Max, MaxMagnitude, MaxMagnitudeNumber, MaxNumber, Min, MinMagnitude, MinMagnitudeNumber, and MinNumber for the vector types

* Expose Clamp on the various vector types

* Ensure mono handles the various zero and low-cost vector conversions

* Apply formatting patch

* Ensure that TensorPrimitives uses the in-box vector operations on .NET 9+

* Fix some build failures

* Workaround a MonoJIT assertion

* Ensure Hypot for double handles insignificant results

* Remove part of the mono changes that were extracted to a separate PR

* Apply suggestions from code review

Co-authored-by: Stephen Toub <[email protected]>

* Ensure tests are added for the new vector APIs

* Fix the mono handling for IsNaN, IsNegative, and IsPositive

* Use the right op for WASM

* Fix a round test to correctly expect -0

* Fix some tests where the wrong parameter counts were being passed

* Ensure APIs are correctly handled for Vector<T>

* Fix the mono handling for OP_XCOMPARE_FP

* Have Mono use the proper klass for IsPositive/IsNegative since we're reinterpreting

* Ensure Mono looks up the class namespace

* Ensure mono inserts xcast where required and handles MultiplyAddEstimate

* Add missing underscores to fix the mono build

* Add the if is_element_type_primitive check to MultiplyAddEstimate for mono

* Pass the right klass on Mono

* Ensure mono sets the metadata for add_ins

* Ensure mono passes down the cast arg0

* Fix the lerp for Mono to match the managed impl

* Ensure mono lerp uses ins_amount for scaling y

* Use gtCloneExpr after the first fgMakeMultiUse if we need another copy

* Combine the SN_IsNegative and SN_IsPositive logic

* Update src/mono/mono/mini/simd-intrinsics.c

---------

Co-authored-by: Stephen Toub <[email protected]>
  • Loading branch information
tannergooding and stephentoub authored Jul 10, 2024
1 parent c7fa446 commit 4a1a076
Show file tree
Hide file tree
Showing 70 changed files with 12,134 additions and 3,418 deletions.
43 changes: 43 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3292,6 +3292,31 @@ class Compiler
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdIsNaNNode(var_types type,
GenTree* op1,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdIsNegativeNode(var_types type,
GenTree* op1,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdIsPositiveNode(var_types type,
GenTree* op1,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdIsPositiveInfinityNode(var_types type,
GenTree* op1,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdIsZeroNode(var_types type,
GenTree* op1,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdLoadNode(
var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize);

Expand All @@ -3307,18 +3332,33 @@ class Compiler
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdMaxNativeNode(var_types type,
GenTree* op1,
GenTree* op2,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdMinNode(var_types type,
GenTree* op1,
GenTree* op2,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdMinNativeNode(var_types type,
GenTree* op1,
GenTree* op2,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdNarrowNode(var_types type,
GenTree* op1,
GenTree* op2,
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdRoundNode(
var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize);

GenTree* gtNewSimdShuffleNode(var_types type,
GenTree* op1,
GenTree* op2,
Expand Down Expand Up @@ -3356,6 +3396,9 @@ class Compiler
CorInfoType simdBaseJitType,
unsigned simdSize);

GenTree* gtNewSimdTruncNode(
var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize);

GenTree* gtNewSimdUnOpNode(genTreeOps op,
var_types type,
GenTree* op1,
Expand Down
Loading

0 comments on commit 4a1a076

Please sign in to comment.