Improve the codegen of the vector accelerated `System.Numerics.*` types (#81335)
authorTanner Gooding <tagoo@outlook.com>
Thu, 2 Feb 2023 06:21:11 +0000 (22:21 -0800)
committerGitHub <noreply@github.com>
Thu, 2 Feb 2023 06:21:11 +0000 (22:21 -0800)
commit90401dde75a71d8e5ea24b351cffd6424b1051db
tree9e46b095617bc3db1108db2e5716ab9e89219d01
parent4354abd606119bd9fb0fdefa9f3c0f58f414bfa9
Improve the codegen of the vector accelerated `System.Numerics.*` types (#81335)

* Allow Quaternion and Plane to be imported as TYP_SIMD16

* Add some minimal intrinsification of Quaternion and Plane

* Ensure Vector indexers are marked readonly

* Ensure the vector constant properties are intrinsic

* Ensure that the vector GetElement and WithElement APIs are intrinsic

* Ensure vector division by scalar is intrinsic

* Minor cleanup to vector files

* Ensure vector arithmetic functions are consistently intrinsic

* Ensure creating a plane from a vector4 is intrinsic

* Ensure accessing the Normal field of a Plane is efficient

* Ensure Quaternion and Plane return the correct SimdAsHWIntrinsicClassId

* Specially optimize Create(Dot(..., ...)) and Create(Sqrt(Dot(..., ...)))

* Ensure vector clamp is intrinsic

* Ensure vector lerp is intrinsic

* Ensure vector length is intrinsic

* Ensure vector normalize is intrinsic

* Ensure vector distance is intrinsic

* Optimize the vector transform by matrix methods

* Ensure quaternion conjugate and inverse are intrinsic

* Fixing assert, formatting, and build failure

* Ensure Quaternion.Inverse uses LengthSquared not Length

* Ensure Create APIs are correctly imported as intrinsic

* Ensure we don't assert for AltJit

* Ensure lowering DotProd doesn't break CSE for scalar vs vector results

* Minimally fixup Mono for the new intrinsics

* Ensure SN_GetElement doesn't raise an assert

* Ensure get_UnitW is ordered correctly for Mono

* Try to fix SN_GetElement

* Fix SN_WithElement for Mono

* Resolving mono formatting feedback
25 files changed:
src/coreclr/jit/compiler.h
src/coreclr/jit/gentree.cpp
src/coreclr/jit/lclmorph.cpp
src/coreclr/jit/lowerarmarch.cpp
src/coreclr/jit/lowerxarch.cpp
src/coreclr/jit/morph.cpp
src/coreclr/jit/simd.cpp
src/coreclr/jit/simdashwintrinsic.cpp
src/coreclr/jit/simdashwintrinsic.h
src/coreclr/jit/simdashwintrinsiclistarm64.h
src/coreclr/jit/simdashwintrinsiclistxarch.h
src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Numerics/Plane.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Quaternion.Extensions.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Numerics/Quaternion.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.Extensions.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector3.Extensions.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector3.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.Extensions.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector4.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs
src/mono/mono/mini/simd-intrinsics.c
src/mono/mono/mini/simd-methods.h