Skip to content

Commit

Permalink
Change Vector2/3/4, Quaternion, Plane, Vector<T>, and Vector64/128/25…
Browse files Browse the repository at this point in the history
…6/512<T> to be implemented in managed where trivially possible (#102301)

* Change Vector4 to be implemented entirely in managed

* Change Plane to be implemented entirely in managed

* Change Quaternion to be implemented entirely in managed

* Avoid accidental recursion on Mono

* Change Vector2/3, Vector<T>, and Vector64/128/256/512<T> to be implemented in managed where trivially possible

* Don't regress the implementation of Dot

* Fixing the handling of Vector512.CreateScalar

* Continue tracking the System.Numerics and System.Runtime.Intrinsics APIs as intrinsic for the profitability boost

* Don't use Unsafe.BitCast on Mono
  • Loading branch information
tannergooding authored Jun 5, 2024
1 parent 0c5fccf commit 2a6bf6f
Show file tree
Hide file tree
Showing 28 changed files with 368 additions and 2,983 deletions.
91 changes: 0 additions & 91 deletions src/coreclr/jit/fgbasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,10 +1400,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
case NI_Vector3_Create:
case NI_Vector3_CreateBroadcast:
case NI_Vector3_CreateFromVector2:
case NI_Vector4_Create:
case NI_Vector4_CreateBroadcast:
case NI_Vector4_CreateFromVector2:
case NI_Vector4_CreateFromVector3:
case NI_Vector128_Create:
case NI_Vector128_CreateScalar:
case NI_Vector128_CreateScalarUnsafe:
Expand Down Expand Up @@ -1630,82 +1626,6 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
break;
}

#if defined(FEATURE_HW_INTRINSICS)
#if defined(TARGET_ARM64)
case NI_Vector64_As:
case NI_Vector64_AsByte:
case NI_Vector64_AsDouble:
case NI_Vector64_AsInt16:
case NI_Vector64_AsInt32:
case NI_Vector64_AsInt64:
case NI_Vector64_AsNInt:
case NI_Vector64_AsNUInt:
case NI_Vector64_AsSByte:
case NI_Vector64_AsSingle:
case NI_Vector64_AsUInt16:
case NI_Vector64_AsUInt32:
case NI_Vector64_AsUInt64:
case NI_Vector64_op_UnaryPlus:
#endif // TARGET_XARCH
case NI_Vector128_As:
case NI_Vector128_AsByte:
case NI_Vector128_AsDouble:
case NI_Vector128_AsInt16:
case NI_Vector128_AsInt32:
case NI_Vector128_AsInt64:
case NI_Vector128_AsNInt:
case NI_Vector128_AsNUInt:
case NI_Vector128_AsSByte:
case NI_Vector128_AsSingle:
case NI_Vector128_AsUInt16:
case NI_Vector128_AsUInt32:
case NI_Vector128_AsUInt64:
case NI_Vector128_AsVector4:
case NI_Vector128_op_UnaryPlus:
case NI_VectorT_As:
case NI_VectorT_AsVectorByte:
case NI_VectorT_AsVectorDouble:
case NI_VectorT_AsVectorInt16:
case NI_VectorT_AsVectorInt32:
case NI_VectorT_AsVectorInt64:
case NI_VectorT_AsVectorNInt:
case NI_VectorT_AsVectorNUInt:
case NI_VectorT_AsVectorSByte:
case NI_VectorT_AsVectorSingle:
case NI_VectorT_AsVectorUInt16:
case NI_VectorT_AsVectorUInt32:
case NI_VectorT_AsVectorUInt64:
case NI_VectorT_op_UnaryPlus:
#if defined(TARGET_XARCH)
case NI_Vector256_As:
case NI_Vector256_AsByte:
case NI_Vector256_AsDouble:
case NI_Vector256_AsInt16:
case NI_Vector256_AsInt32:
case NI_Vector256_AsInt64:
case NI_Vector256_AsNInt:
case NI_Vector256_AsNUInt:
case NI_Vector256_AsSByte:
case NI_Vector256_AsSingle:
case NI_Vector256_AsUInt16:
case NI_Vector256_AsUInt32:
case NI_Vector256_AsUInt64:
case NI_Vector256_op_UnaryPlus:
case NI_Vector512_As:
case NI_Vector512_AsByte:
case NI_Vector512_AsDouble:
case NI_Vector512_AsInt16:
case NI_Vector512_AsInt32:
case NI_Vector512_AsInt64:
case NI_Vector512_AsNInt:
case NI_Vector512_AsNUInt:
case NI_Vector512_AsSByte:
case NI_Vector512_AsSingle:
case NI_Vector512_AsUInt16:
case NI_Vector512_AsUInt32:
case NI_Vector512_AsUInt64:
#endif // TARGET_XARCH
#endif // FEATURE_HW_INTRINSICS
case NI_SRCS_UNSAFE_As:
case NI_SRCS_UNSAFE_AsRef:
case NI_SRCS_UNSAFE_BitCast:
Expand All @@ -1724,27 +1644,16 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, Fixed
#if defined(TARGET_ARM64)
case NI_Vector64_get_AllBitsSet:
case NI_Vector64_get_One:
case NI_Vector64_get_Zero:
#endif // TARGET_ARM64
case NI_Vector2_get_One:
case NI_Vector2_get_Zero:
case NI_Vector3_get_One:
case NI_Vector3_get_Zero:
case NI_Vector4_get_One:
case NI_Vector4_get_Zero:
case NI_Vector128_get_AllBitsSet:
case NI_Vector128_get_One:
case NI_Vector128_get_Zero:
case NI_VectorT_get_AllBitsSet:
case NI_VectorT_get_One:
case NI_VectorT_get_Zero:
#if defined(TARGET_XARCH)
case NI_Vector256_get_AllBitsSet:
case NI_Vector256_get_One:
case NI_Vector256_get_Zero:
case NI_Vector512_get_AllBitsSet:
case NI_Vector512_get_One:
case NI_Vector512_get_Zero:
#endif // TARGET_XARCH
#endif // FEATURE_HW_INTRINSICS
{
Expand Down
73 changes: 0 additions & 73 deletions src/coreclr/jit/hwintrinsicarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Add:
case NI_Vector128_Add:
case NI_Vector64_op_Addition:
case NI_Vector128_op_Addition:
{
Expand All @@ -569,34 +567,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_As:
case NI_Vector64_AsByte:
case NI_Vector64_AsDouble:
case NI_Vector64_AsInt16:
case NI_Vector64_AsInt32:
case NI_Vector64_AsInt64:
case NI_Vector64_AsNInt:
case NI_Vector64_AsNUInt:
case NI_Vector64_AsSByte:
case NI_Vector64_AsSingle:
case NI_Vector64_AsUInt16:
case NI_Vector64_AsUInt32:
case NI_Vector64_AsUInt64:
case NI_Vector128_As:
case NI_Vector128_AsByte:
case NI_Vector128_AsDouble:
case NI_Vector128_AsInt16:
case NI_Vector128_AsInt32:
case NI_Vector128_AsInt64:
case NI_Vector128_AsNInt:
case NI_Vector128_AsNUInt:
case NI_Vector128_AsSByte:
case NI_Vector128_AsSingle:
case NI_Vector128_AsUInt16:
case NI_Vector128_AsUInt32:
case NI_Vector128_AsUInt64:
case NI_Vector128_AsVector:
case NI_Vector128_AsVector4:
{
assert(!sig->hasThis());
assert(numArgs == 1);
Expand Down Expand Up @@ -711,8 +682,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_BitwiseAnd:
case NI_Vector128_BitwiseAnd:
case NI_Vector64_op_BitwiseAnd:
case NI_Vector128_op_BitwiseAnd:
{
Expand All @@ -725,8 +694,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_BitwiseOr:
case NI_Vector128_BitwiseOr:
case NI_Vector64_op_BitwiseOr:
case NI_Vector128_op_BitwiseOr:
{
Expand Down Expand Up @@ -1095,8 +1062,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Divide:
case NI_Vector128_Divide:
case NI_Vector64_op_Division:
case NI_Vector128_op_Division:
{
Expand Down Expand Up @@ -1153,8 +1118,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_EqualsAll:
case NI_Vector128_EqualsAll:
case NI_Vector64_op_Equality:
case NI_Vector128_op_Equality:
{
Expand Down Expand Up @@ -1400,14 +1363,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_get_Zero:
case NI_Vector128_get_Zero:
{
assert(sig->numArgs == 0);
retNode = gtNewZeroConNode(retType);
break;
}

case NI_Vector64_GetElement:
case NI_Vector128_GetElement:
{
Expand Down Expand Up @@ -1593,8 +1548,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

case NI_AdvSimd_LoadVector64:
case NI_AdvSimd_LoadVector128:
case NI_Vector64_Load:
case NI_Vector128_Load:
case NI_Vector64_LoadUnsafe:
case NI_Vector128_LoadUnsafe:
{
Expand Down Expand Up @@ -1700,8 +1653,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Multiply:
case NI_Vector128_Multiply:
case NI_Vector64_op_Multiply:
case NI_Vector128_op_Multiply:
{
Expand Down Expand Up @@ -1765,8 +1716,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Negate:
case NI_Vector128_Negate:
case NI_Vector64_op_UnaryNegation:
case NI_Vector128_op_UnaryNegation:
{
Expand All @@ -1776,8 +1725,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_OnesComplement:
case NI_Vector128_OnesComplement:
case NI_Vector64_op_OnesComplement:
case NI_Vector128_op_OnesComplement:
{
Expand All @@ -1800,16 +1747,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_op_UnaryPlus:
case NI_Vector128_op_UnaryPlus:
{
assert(sig->numArgs == 1);
retNode = impSIMDPopStack();
break;
}

case NI_Vector64_Subtract:
case NI_Vector128_Subtract:
case NI_Vector64_op_Subtraction:
case NI_Vector128_op_Subtraction:
{
Expand All @@ -1822,8 +1759,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_ShiftLeft:
case NI_Vector128_ShiftLeft:
case NI_Vector64_op_LeftShift:
case NI_Vector128_op_LeftShift:
{
Expand All @@ -1836,8 +1771,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_ShiftRightArithmetic:
case NI_Vector128_ShiftRightArithmetic:
case NI_Vector64_op_RightShift:
case NI_Vector128_op_RightShift:
{
Expand All @@ -1851,8 +1784,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_ShiftRightLogical:
case NI_Vector128_ShiftRightLogical:
case NI_Vector64_op_UnsignedRightShift:
case NI_Vector128_op_UnsignedRightShift:
{
Expand Down Expand Up @@ -1936,9 +1867,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Store:
case NI_Vector64_StoreUnsafe:
case NI_Vector128_Store:
case NI_Vector128_StoreUnsafe:
{
assert(retType == TYP_VOID);
Expand Down Expand Up @@ -2276,8 +2205,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

case NI_Vector64_Xor:
case NI_Vector128_Xor:
case NI_Vector64_op_ExclusiveOr:
case NI_Vector128_op_ExclusiveOr:
{
Expand Down
Loading

0 comments on commit 2a6bf6f

Please sign in to comment.