From 0935be406d3ba4d76964b15aacbe846b9f4556ec Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Fri, 21 Jun 2024 14:03:08 -0700 Subject: [PATCH] Fix some build failures --- src/coreclr/jit/compiler.h | 6 + src/coreclr/jit/gentree.cpp | 122 ++++++++++++++++++ src/coreclr/jit/hwintrinsicarm64.cpp | 32 +++++ src/coreclr/jit/hwintrinsiclistarm64.h | 4 + src/coreclr/jit/hwintrinsiclistxarch.h | 6 + src/coreclr/jit/hwintrinsicxarch.cpp | 46 +++++++ .../Tensors/TensorPrimitives.Single.cs | 8 +- .../Tensors/netcore/TensorPrimitives.Max.cs | 36 +++++- .../Tensors/netcore/TensorPrimitives.Min.cs | 6 +- .../Tensors/netcore/TensorPrimitives.Round.cs | 2 + .../TensorPrimitives.Single.netcore.cs | 4 - .../ref/System.Numerics.Vectors.cs | 5 + .../src/System/Numerics/Vector.cs | 10 +- .../System/Runtime/Intrinsics/Vector128.cs | 10 +- .../System/Runtime/Intrinsics/Vector256.cs | 10 +- .../System/Runtime/Intrinsics/Vector512.cs | 10 +- .../src/System/Runtime/Intrinsics/Vector64.cs | 10 +- .../ref/System.Runtime.Intrinsics.cs | 20 +++ src/mono/mono/mini/simd-intrinsics.c | 27 ++-- src/mono/mono/mini/simd-methods.h | 1 + 20 files changed, 323 insertions(+), 52 deletions(-) diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 76819a08c95ec8..aafcfab6043f90 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -3353,6 +3353,9 @@ class Compiler CorInfoType simdBaseJitType, unsigned simdSize); + GenTree* gtNewSimdRoundNode( + var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize); + GenTree* gtNewSimdShuffleNode(var_types type, GenTree* op1, GenTree* op2, @@ -3390,6 +3393,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, diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 973ebe5f03ffb5..d661402d8aa549 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -25965,6 +25965,67 @@ GenTree* Compiler::gtNewSimdNarrowNode( #endif // !TARGET_XARCH && !TARGET_ARM64 } +//------------------------------------------------------------------------ +// gtNewSimdRoundNode: Creates a new simd Round node +// +// Arguments: +// type -- The type of the node +// op1 -- The node to round +// simdBaseJitType -- the base jit type of the node +// simdSize -- the simd size of the node +// +// Return Value: +// The round node +// +GenTree* Compiler::gtNewSimdRoundNode(var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize) +{ + assert(IsBaselineSimdIsaSupportedDebugOnly()); + + assert(varTypeIsSIMD(type)); + assert(getSIMDTypeForSize(simdSize) == type); + + assert(op1 != nullptr); + assert(op1->TypeIs(type)); + + var_types simdBaseType = JitType2PreciseVarType(simdBaseJitType); + assert(varTypeIsFloating(simdBaseType)); + + NamedIntrinsic intrinsic = NI_Illegal; + +#if defined(TARGET_XARCH) + if (simdSize == 32) + { + assert(compIsaSupportedDebugOnly(InstructionSet_AVX)); + intrinsic = NI_AVX_RoundToNearestInteger; + } + else if (simdSize == 64) + { + assert(compIsaSupportedDebugOnly(InstructionSet_AVX512F)); + GenTree* op2 = gtNewIconNode(static_cast(FloatRoundingMode::ToNearestInteger)); + return gtNewSimdHWIntrinsicNode(type, op1, op2, NI_AVX512F_RoundScale, simdBaseJitType, simdSize); + } + else + { + assert(compIsaSupportedDebugOnly(InstructionSet_SSE41)); + intrinsic = NI_SSE41_RoundToNearestInteger; + } +#elif defined(TARGET_ARM64) + if (simdBaseType == TYP_DOUBLE) + { + intrinsic = (simdSize == 8) ? NI_AdvSimd_RoundToNearestScalar : NI_AdvSimd_Arm64_RoundToNearest; + } + else + { + intrinsic = NI_AdvSimd_RoundToNearest; + } +#else +#error Unsupported platform +#endif // !TARGET_XARCH && !TARGET_ARM64 + + assert(intrinsic != NI_Illegal); + return gtNewSimdHWIntrinsicNode(type, op1, intrinsic, simdBaseJitType, simdSize); +} + GenTree* Compiler::gtNewSimdShuffleNode( var_types type, GenTree* op1, GenTree* op2, CorInfoType simdBaseJitType, unsigned simdSize) { @@ -26904,6 +26965,67 @@ GenTree* Compiler::gtNewSimdToScalarNode(var_types type, GenTree* op1, CorInfoTy return gtNewSimdHWIntrinsicNode(type, op1, intrinsic, simdBaseJitType, simdSize); } +//------------------------------------------------------------------------ +// gtNewSimdTruncNode: Creates a new simd Truncate node +// +// Arguments: +// type -- The type of the node +// op1 -- The node to truncate +// simdBaseJitType -- the base jit type of the node +// simdSize -- the simd size of the node +// +// Return Value: +// The truncate node +// +GenTree* Compiler::gtNewSimdTruncNode(var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize) +{ + assert(IsBaselineSimdIsaSupportedDebugOnly()); + + assert(varTypeIsSIMD(type)); + assert(getSIMDTypeForSize(simdSize) == type); + + assert(op1 != nullptr); + assert(op1->TypeIs(type)); + + var_types simdBaseType = JitType2PreciseVarType(simdBaseJitType); + assert(varTypeIsFloating(simdBaseType)); + + NamedIntrinsic intrinsic = NI_Illegal; + +#if defined(TARGET_XARCH) + if (simdSize == 32) + { + assert(compIsaSupportedDebugOnly(InstructionSet_AVX)); + intrinsic = NI_AVX_RoundToZero; + } + else if (simdSize == 64) + { + assert(compIsaSupportedDebugOnly(InstructionSet_AVX512F)); + GenTree* op2 = gtNewIconNode(static_cast(FloatRoundingMode::ToZero)); + return gtNewSimdHWIntrinsicNode(type, op1, op2, NI_AVX512F_RoundScale, simdBaseJitType, simdSize); + } + else + { + assert(compIsaSupportedDebugOnly(InstructionSet_SSE41)); + intrinsic = NI_SSE41_RoundToZero; + } +#elif defined(TARGET_ARM64) + if (simdBaseType == TYP_DOUBLE) + { + intrinsic = (simdSize == 8) ? NI_AdvSimd_RoundToZero : NI_AdvSimd_Arm64_RoundToZero; + } + else + { + intrinsic = NI_AdvSimd_RoundToZero; + } +#else +#error Unsupported platform +#endif // !TARGET_XARCH && !TARGET_ARM64 + + assert(intrinsic != NI_Illegal); + return gtNewSimdHWIntrinsicNode(type, op1, intrinsic, simdBaseJitType, simdSize); +} + GenTree* Compiler::gtNewSimdUnOpNode( genTreeOps op, var_types type, GenTree* op1, CorInfoType simdBaseJitType, unsigned simdSize) { diff --git a/src/coreclr/jit/hwintrinsicarm64.cpp b/src/coreclr/jit/hwintrinsicarm64.cpp index 8734b4c05d8a2f..dd6941ac03f4b6 100644 --- a/src/coreclr/jit/hwintrinsicarm64.cpp +++ b/src/coreclr/jit/hwintrinsicarm64.cpp @@ -1956,6 +1956,22 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Vector64_Round: + case NI_Vector128_Round: + { + assert(sig->numArgs == 1); + + if (!varTypeIsFloating(simdBaseType)) + { + retNode = impSIMDPopStack(); + break; + } + + op1 = impSIMDPopStack(); + retNode = gtNewSimdRoundNode(retType, op1, simdBaseJitType, simdSize); + break; + } + case NI_Vector64_Shuffle: case NI_Vector128_Shuffle: { @@ -2298,6 +2314,22 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Vector64_Truncate: + case NI_Vector128_Truncate: + { + assert(sig->numArgs == 1); + + if (!varTypeIsFloating(simdBaseType)) + { + retNode = impSIMDPopStack(); + break; + } + + op1 = impSIMDPopStack(); + retNode = gtNewSimdTruncNode(retType, op1, simdBaseJitType, simdSize); + break; + } + case NI_Vector64_WidenLower: case NI_Vector128_WidenLower: { diff --git a/src/coreclr/jit/hwintrinsiclistarm64.h b/src/coreclr/jit/hwintrinsiclistarm64.h index 9b7bdd37a94ba0..7de5af49252f07 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64.h +++ b/src/coreclr/jit/hwintrinsiclistarm64.h @@ -98,6 +98,7 @@ HARDWARE_INTRINSIC(Vector64, op_Subtraction, HARDWARE_INTRINSIC(Vector64, op_UnaryNegation, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector64, op_UnaryPlus, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector64, op_UnsignedRightShift, 8, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) +HARDWARE_INTRINSIC(Vector64, Round, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector64, Shuffle, 8, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector64, Sqrt, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector64, StoreAligned, 8, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) @@ -107,6 +108,7 @@ HARDWARE_INTRINSIC(Vector64, Sum, HARDWARE_INTRINSIC(Vector64, ToScalar, 8, 1, true, {INS_smov, INS_umov, INS_smov, INS_umov, INS_smov, INS_umov, INS_umov, INS_umov, INS_dup, INS_dup}, HW_Category_SIMD, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SIMDScalar|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector64, ToVector128, 8, 1, true, {INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov}, HW_Category_SIMD, HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector64, ToVector128Unsafe, 8, 1, true, {INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov, INS_mov}, HW_Category_SIMD, HW_Flag_SpecialCodeGen) +HARDWARE_INTRINSIC(Vector64, Truncate, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector64, WidenLower, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector64, WidenUpper, 8, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector64, WithElement, 8, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialImport) @@ -208,6 +210,7 @@ HARDWARE_INTRINSIC(Vector128, op_OnesComplement, HARDWARE_INTRINSIC(Vector128, op_Subtraction, 16, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, op_UnaryNegation, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, op_UnaryPlus, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) +HARDWARE_INTRINSIC(Vector128, Round, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, Shuffle, 16, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector128, Sqrt, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, StoreAligned, 16, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) @@ -215,6 +218,7 @@ HARDWARE_INTRINSIC(Vector128, StoreAlignedNonTemporal, HARDWARE_INTRINSIC(Vector128, StoreUnsafe, 16, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, Sum, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, ToScalar, 16, 1, true, {INS_smov, INS_umov, INS_smov, INS_umov, INS_smov, INS_umov, INS_umov, INS_umov, INS_dup, INS_dup}, HW_Category_SIMD, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SIMDScalar|HW_Flag_SpecialCodeGen) +HARDWARE_INTRINSIC(Vector128, Truncate, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, WidenLower, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, WidenUpper, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, WithElement, 16, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialImport) diff --git a/src/coreclr/jit/hwintrinsiclistxarch.h b/src/coreclr/jit/hwintrinsiclistxarch.h index 191dce19f725e4..afc1eacebb85d9 100644 --- a/src/coreclr/jit/hwintrinsiclistxarch.h +++ b/src/coreclr/jit/hwintrinsiclistxarch.h @@ -118,6 +118,7 @@ HARDWARE_INTRINSIC(Vector128, op_Subtraction, HARDWARE_INTRINSIC(Vector128, op_UnaryNegation, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, op_UnaryPlus, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, op_UnsignedRightShift, 16, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) +HARDWARE_INTRINSIC(Vector128, Round, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, Shuffle, 16, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector128, Sqrt, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, StoreAligned, 16, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) @@ -128,6 +129,7 @@ HARDWARE_INTRINSIC(Vector128, ToScalar, HARDWARE_INTRINSIC(Vector128, ToVector256, 16, 1, true, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movups, INS_movupd}, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128, ToVector256Unsafe, 16, 1, true, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movups, INS_movupd}, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128, ToVector512, 16, 1, true, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_vmovdqu64, INS_vmovdqu64, INS_movups, INS_movupd}, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(Vector128, Truncate, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector128, WidenLower, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, WidenUpper, 16, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128, WithElement, 16, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) @@ -224,6 +226,7 @@ HARDWARE_INTRINSIC(Vector256, op_Subtraction, HARDWARE_INTRINSIC(Vector256, op_UnaryNegation, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector256, op_UnaryPlus, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_AvxOnlyCompatible) HARDWARE_INTRINSIC(Vector256, op_UnsignedRightShift, 32, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) +HARDWARE_INTRINSIC(Vector256, Round, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector256, Shuffle, 32, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector256, Sqrt, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_AvxOnlyCompatible) HARDWARE_INTRINSIC(Vector256, StoreAligned, 32, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg|HW_Flag_AvxOnlyCompatible) @@ -233,6 +236,7 @@ HARDWARE_INTRINSIC(Vector256, Sum, HARDWARE_INTRINSIC(Vector256, ToScalar, 32, 1, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movss, INS_movsd_simd}, HW_Category_SIMDScalar, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg|HW_Flag_AvxOnlyCompatible) HARDWARE_INTRINSIC(Vector256, ToVector512, 32, 1, true, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_vmovdqu64, INS_vmovdqu64, INS_movups, INS_movupd}, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector256, ToVector512Unsafe, 32, 1, true, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_vmovdqu64, INS_vmovdqu64, INS_movups, INS_movupd}, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(Vector256, Truncate, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector256, WidenLower, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector256, WidenUpper, 32, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector256, WithElement, 32, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_AvxOnlyCompatible) @@ -331,6 +335,7 @@ HARDWARE_INTRINSIC(Vector512, op_Subtraction, HARDWARE_INTRINSIC(Vector512, op_UnaryNegation, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector512, op_UnaryPlus, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector512, op_UnsignedRightShift, 64, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) +HARDWARE_INTRINSIC(Vector512, Round, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector512, Shuffle, 64, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen) HARDWARE_INTRINSIC(Vector512, Sqrt, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector512, StoreAligned, 64, 2, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) @@ -338,6 +343,7 @@ HARDWARE_INTRINSIC(Vector512, StoreAlignedNonTemporal, HARDWARE_INTRINSIC(Vector512, StoreUnsafe, 64, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector512, Sum, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector512, ToScalar, 64, 1, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movss, INS_movsd_simd}, HW_Category_SIMDScalar, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(Vector512, Truncate, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(Vector512, WidenLower, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector512, WidenUpper, 64, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector512, WithElement, 64, 3, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Helper, HW_Flag_SpecialImport|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) diff --git a/src/coreclr/jit/hwintrinsicxarch.cpp b/src/coreclr/jit/hwintrinsicxarch.cpp index e888a5b8fac7f8..2060c0ba273f47 100644 --- a/src/coreclr/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/jit/hwintrinsicxarch.cpp @@ -3047,6 +3047,29 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Vector128_Round: + case NI_Vector256_Round: + case NI_Vector512_Round: + { + assert(sig->numArgs == 1); + + if (!varTypeIsFloating(simdBaseType)) + { + retNode = impSIMDPopStack(); + break; + } + + if ((simdSize < 32) && !compOpportunisticallyDependsOn(InstructionSet_SSE41)) + { + // Round is only supported for floating-point types on SSE4.1 or later + break; + } + + op1 = impSIMDPopStack(); + retNode = gtNewSimdRoundNode(retType, op1, simdBaseJitType, simdSize); + break; + } + case NI_Vector128_Shuffle: case NI_Vector256_Shuffle: case NI_Vector512_Shuffle: @@ -3278,6 +3301,29 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Vector128_Truncate: + case NI_Vector256_Truncate: + case NI_Vector512_Truncate: + { + assert(sig->numArgs == 1); + + if (!varTypeIsFloating(simdBaseType)) + { + retNode = impSIMDPopStack(); + break; + } + + if ((simdSize < 32) && !compOpportunisticallyDependsOn(InstructionSet_SSE41)) + { + // Truncate is only supported for floating-point types on SSE4.1 or later + break; + } + + op1 = impSIMDPopStack(); + retNode = gtNewSimdTruncNode(retType, op1, simdBaseJitType, simdSize); + break; + } + case NI_Vector256_GetLower: { assert(sig->numArgs == 1); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Single.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Single.cs index a8d4c6815ca406..96150e89108aad 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Single.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/TensorPrimitives.Single.cs @@ -440,7 +440,7 @@ public static float Max(ReadOnlySpan x) => /// /// public static void Max(ReadOnlySpan x, ReadOnlySpan y, Span destination) => - InvokeSpanSpanIntoSpan(x, y, destination); + InvokeSpanSpanIntoSpan(x, y, destination); /// Searches for the single-precision floating-point number with the largest magnitude in the specified tensor. /// The tensor, represented as a span. @@ -476,7 +476,7 @@ public static float MaxMagnitude(ReadOnlySpan x) => /// /// public static void MaxMagnitude(ReadOnlySpan x, ReadOnlySpan y, Span destination) => - InvokeSpanSpanIntoSpan(x, y, destination); + InvokeSpanSpanIntoSpan(x, y, destination); /// Searches for the smallest single-precision floating-point number in the specified tensor. /// The tensor, represented as a span. @@ -517,7 +517,7 @@ public static float Min(ReadOnlySpan x) => /// /// public static void Min(ReadOnlySpan x, ReadOnlySpan y, Span destination) => - InvokeSpanSpanIntoSpan(x, y, destination); + InvokeSpanSpanIntoSpan(x, y, destination); /// Searches for the single-precision floating-point number with the smallest magnitude in the specified tensor. /// The tensor, represented as a span. @@ -558,7 +558,7 @@ public static float MinMagnitude(ReadOnlySpan x) => /// /// public static void MinMagnitude(ReadOnlySpan x, ReadOnlySpan y, Span destination) => - InvokeSpanSpanIntoSpan(x, y, destination); + InvokeSpanSpanIntoSpan(x, y, destination); /// Computes the element-wise product of single-precision floating-point numbers in the specified tensors. /// The first tensor, represented as a span. diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Max.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Max.cs index 3a9c370e0078dd..faa3f4e3ddb779 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Max.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Max.cs @@ -187,11 +187,13 @@ private static Vector512 IsNaN(Vector512 vector) #endif } -#if !NET9_0_OR_GREATER /// Gets whether each specified is negative. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128 IsNegative(Vector128 vector) { +#if NET9_0_OR_GREATER + return Vector128.IsNegative(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -212,12 +214,16 @@ private static Vector128 IsNegative(Vector128 vector) } return Vector128.LessThan(vector, Vector128.Zero); +#endif } /// Gets whether each specified is negative. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 IsNegative(Vector256 vector) { +#if NET9_0_OR_GREATER + return Vector256.IsNegative(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -238,12 +244,16 @@ private static Vector256 IsNegative(Vector256 vector) } return Vector256.LessThan(vector, Vector256.Zero); +#endif } /// Gets whether each specified is negative. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector512 IsNegative(Vector512 vector) { +#if NET9_0_OR_GREATER + return Vector512.IsNegative(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -264,12 +274,16 @@ private static Vector512 IsNegative(Vector512 vector) } return Vector512.LessThan(vector, Vector512.Zero); +#endif } /// Gets whether each specified is positive. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector128 IsPositive(Vector128 vector) { +#if NET9_0_OR_GREATER + return Vector128.IsPositive(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -290,12 +304,16 @@ private static Vector128 IsPositive(Vector128 vector) } return Vector128.GreaterThanOrEqual(vector, Vector128.Zero); +#endif } /// Gets whether each specified is positive. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector256 IsPositive(Vector256 vector) { +#if NET9_0_OR_GREATER + return Vector256.IsPositive(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -316,12 +334,16 @@ private static Vector256 IsPositive(Vector256 vector) } return Vector256.GreaterThanOrEqual(vector, Vector256.Zero); +#endif } /// Gets whether each specified is positive. [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Vector512 IsPositive(Vector512 vector) { +#if NET9_0_OR_GREATER + return Vector512.IsPositive(vector); +#else if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) || (typeof(T) == typeof(uint)) @@ -342,14 +364,14 @@ private static Vector512 IsPositive(Vector512 vector) } return Vector512.GreaterThanOrEqual(vector, Vector512.Zero); - } #endif + } - /// - /// This is the same as - /// with an identity transform, except it early exits on NaN. - /// - private static T MinMaxCore(ReadOnlySpan x) + /// + /// This is the same as + /// with an identity transform, except it early exits on NaN. + /// + private static T MinMaxCore(ReadOnlySpan x) where T : INumberBase where TMinMaxOperator : struct, IAggregationOperator { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Min.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Min.cs index 2159d81b3f49fc..430bfa76441765 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Min.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Min.cs @@ -91,7 +91,7 @@ public static Vector128 Invoke(Vector128 x, Vector128 y) if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { return Vector128.ConditionalSelect( - (Vector128.Equals(x, y) & Vector128.IsNegative(x)) | Vector128.IsNaN(x) | Vector128.LessThan(x, y), + (Vector128.Equals(x, y) & IsNegative(x)) | IsNaN(x) | Vector128.LessThan(x, y), x, y ); @@ -108,7 +108,7 @@ public static Vector256 Invoke(Vector256 x, Vector256 y) if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { return Vector256.ConditionalSelect( - (Vector256.Equals(x, y) & Vector256.IsNegative(x)) | Vector256.IsNaN(x) | Vector256.LessThan(x, y), + (Vector256.Equals(x, y) & IsNegative(x)) | IsNaN(x) | Vector256.LessThan(x, y), x, y ); @@ -125,7 +125,7 @@ public static Vector512 Invoke(Vector512 x, Vector512 y) if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { return Vector512.ConditionalSelect( - (Vector512.Equals(x, y) & Vector512.IsNegative(x)) | Vector512.IsNaN(x) | Vector512.LessThan(x, y), + (Vector512.Equals(x, y) & IsNegative(x)) | IsNaN(x) | Vector512.LessThan(x, y), x, y ); diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Round.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Round.cs index 439b5dbfdcfb11..bd39bd0cdf9f2f 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Round.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Round.cs @@ -171,8 +171,10 @@ public static void Round(ReadOnlySpan x, int digits, MidpointRounding mode public static T Invoke(T x) => T.Round(x); +#if !NET9_0_OR_GREATER private const float SingleBoundary = 8388608.0f; // 2^23 private const double DoubleBoundary = 4503599627370496.0; // 2^52 +#endif public static Vector128 Invoke(Vector128 x) { diff --git a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Single.netcore.cs b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Single.netcore.cs index 67d09e0ce4a181..a15a43d2178a00 100644 --- a/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Single.netcore.cs +++ b/src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.Single.netcore.cs @@ -21,13 +21,9 @@ global using LogOperator_Single = System.Numerics.Tensors.TensorPrimitives.LogOperator; global using Log2Operator_Single = System.Numerics.Tensors.TensorPrimitives.Log2Operator; global using MaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxOperator; -global using MaxPropagateNaNOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxOperator; global using MaxMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxMagnitudeOperator; -global using MaxMagnitudePropagateNaNOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxMagnitudeOperator; global using MinOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinOperator; -global using MinPropagateNaNOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinOperator; global using MinMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinMagnitudeOperator; -global using MinMagnitudePropagateNaNOperator_Single = System.Numerics.Tensors.TensorPrimitives.MinMagnitudeOperator; global using MultiplyAddOperator_Single = System.Numerics.Tensors.TensorPrimitives.MultiplyAddOperator; global using NegateOperator_Single = System.Numerics.Tensors.TensorPrimitives.NegateOperator; global using IdentityOperator_Single = System.Numerics.Tensors.TensorPrimitives.IdentityOperator; diff --git a/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs b/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs index a0d3ae85e99af7..fba0c8dbcd4be6 100644 --- a/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs +++ b/src/libraries/System.Numerics.Vectors/ref/System.Numerics.Vectors.cs @@ -300,6 +300,11 @@ public static partial class Vector public static System.Numerics.Vector GreaterThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector Hypot(System.Numerics.Vector x, System.Numerics.Vector y) { throw null; } public static System.Numerics.Vector Hypot(System.Numerics.Vector x, System.Numerics.Vector y) { throw null; } + public static System.Numerics.Vector IsNaN(System.Numerics.Vector vector) { throw null; } + public static System.Numerics.Vector IsNegative(System.Numerics.Vector vector) { throw null; } + public static System.Numerics.Vector IsPositive(System.Numerics.Vector vector) { throw null; } + public static System.Numerics.Vector IsPositiveInfinity(System.Numerics.Vector vector) { throw null; } + public static System.Numerics.Vector IsZero(System.Numerics.Vector vector) { throw null; } public static System.Numerics.Vector Lerp(System.Numerics.Vector x, System.Numerics.Vector y, System.Numerics.Vector amount) { throw null; } public static System.Numerics.Vector Lerp(System.Numerics.Vector x, System.Numerics.Vector y, System.Numerics.Vector amount) { throw null; } public static System.Numerics.Vector LessThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs index 3ab21caa4e5866..9bfd7b581070cc 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs @@ -1189,7 +1189,7 @@ public static Vector Hypot(Vector x, Vector y) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector IsNaN(Vector vector) + public static Vector IsNaN(Vector vector) { if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { @@ -1201,7 +1201,7 @@ internal static Vector IsNaN(Vector vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector IsNegative(Vector vector) + public static Vector IsNegative(Vector vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1228,7 +1228,7 @@ internal static Vector IsNegative(Vector vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector IsPositive(Vector vector) + public static Vector IsPositive(Vector vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1255,7 +1255,7 @@ internal static Vector IsPositive(Vector vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector IsPositiveInfinity(Vector vector) + public static Vector IsPositiveInfinity(Vector vector) { if (typeof(T) == typeof(float)) { @@ -1271,7 +1271,7 @@ internal static Vector IsPositiveInfinity(Vector vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector IsZero(Vector vector) => Equals(vector, Vector.Zero); + public static Vector IsZero(Vector vector) => Equals(vector, Vector.Zero); internal static Vector Lerp(Vector x, Vector y, Vector amount) where T : IFloatingPointIeee754 diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs index 2d88498cc229f3..ea69cf1528c54f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs @@ -1869,7 +1869,7 @@ public static Vector128 Hypot(Vector128 x, Vector128 y) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector128 IsNaN(Vector128 vector) + public static Vector128 IsNaN(Vector128 vector) { if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { @@ -1881,7 +1881,7 @@ internal static Vector128 IsNaN(Vector128 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector128 IsNegative(Vector128 vector) + public static Vector128 IsNegative(Vector128 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1908,7 +1908,7 @@ internal static Vector128 IsNegative(Vector128 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector128 IsPositive(Vector128 vector) + public static Vector128 IsPositive(Vector128 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1935,7 +1935,7 @@ internal static Vector128 IsPositive(Vector128 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector128 IsPositiveInfinity(Vector128 vector) + public static Vector128 IsPositiveInfinity(Vector128 vector) { if (typeof(T) == typeof(float)) { @@ -1951,7 +1951,7 @@ internal static Vector128 IsPositiveInfinity(Vector128 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector128 IsZero(Vector128 vector) => Equals(vector, Vector128.Zero); + public static Vector128 IsZero(Vector128 vector) => Equals(vector, Vector128.Zero); /// [Intrinsic] diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs index 1a69fc6069731a..a2d708b6a88d43 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs @@ -1785,7 +1785,7 @@ public static Vector256 Hypot(Vector256 x, Vector256 y) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector256 IsNaN(Vector256 vector) + public static Vector256 IsNaN(Vector256 vector) { if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { @@ -1797,7 +1797,7 @@ internal static Vector256 IsNaN(Vector256 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector256 IsNegative(Vector256 vector) + public static Vector256 IsNegative(Vector256 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1824,7 +1824,7 @@ internal static Vector256 IsNegative(Vector256 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector256 IsPositive(Vector256 vector) + public static Vector256 IsPositive(Vector256 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1851,7 +1851,7 @@ internal static Vector256 IsPositive(Vector256 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector256 IsPositiveInfinity(Vector256 vector) + public static Vector256 IsPositiveInfinity(Vector256 vector) { if (typeof(T) == typeof(float)) { @@ -1867,7 +1867,7 @@ internal static Vector256 IsPositiveInfinity(Vector256 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector256 IsZero(Vector256 vector) => Equals(vector, Vector256.Zero); + public static Vector256 IsZero(Vector256 vector) => Equals(vector, Vector256.Zero); /// [Intrinsic] diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs index e63af15c915dcc..86cb45ba617876 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs @@ -1848,7 +1848,7 @@ public static Vector512 Hypot(Vector512 x, Vector512 y) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector512 IsNaN(Vector512 vector) + public static Vector512 IsNaN(Vector512 vector) { if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { @@ -1860,7 +1860,7 @@ internal static Vector512 IsNaN(Vector512 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector512 IsNegative(Vector512 vector) + public static Vector512 IsNegative(Vector512 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1887,7 +1887,7 @@ internal static Vector512 IsNegative(Vector512 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector512 IsPositive(Vector512 vector) + public static Vector512 IsPositive(Vector512 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1914,7 +1914,7 @@ internal static Vector512 IsPositive(Vector512 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector512 IsPositiveInfinity(Vector512 vector) + public static Vector512 IsPositiveInfinity(Vector512 vector) { if (typeof(T) == typeof(float)) { @@ -1930,7 +1930,7 @@ internal static Vector512 IsPositiveInfinity(Vector512 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector512 IsZero(Vector512 vector) => Equals(vector, Vector512.Zero); + public static Vector512 IsZero(Vector512 vector) => Equals(vector, Vector512.Zero); /// [Intrinsic] diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs index 65854c8e0f0775..b58700fc2050a1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs @@ -1585,7 +1585,7 @@ public static Vector64 Hypot(Vector64 x, Vector64 y) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector64 IsNaN(Vector64 vector) + public static Vector64 IsNaN(Vector64 vector) { if ((typeof(T) == typeof(float)) || (typeof(T) == typeof(double))) { @@ -1597,7 +1597,7 @@ internal static Vector64 IsNaN(Vector64 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector64 IsNegative(Vector64 vector) + public static Vector64 IsNegative(Vector64 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1624,7 +1624,7 @@ internal static Vector64 IsNegative(Vector64 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector64 IsPositive(Vector64 vector) + public static Vector64 IsPositive(Vector64 vector) { if ((typeof(T) == typeof(byte)) || (typeof(T) == typeof(ushort)) @@ -1651,7 +1651,7 @@ internal static Vector64 IsPositive(Vector64 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector64 IsPositiveInfinity(Vector64 vector) + public static Vector64 IsPositiveInfinity(Vector64 vector) { if (typeof(T) == typeof(float)) { @@ -1667,7 +1667,7 @@ internal static Vector64 IsPositiveInfinity(Vector64 vector) /// [Intrinsic] [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static Vector64 IsZero(Vector64 vector) => Equals(vector, Vector64.Zero); + public static Vector64 IsZero(Vector64 vector) => Equals(vector, Vector64.Zero); internal static Vector64 Lerp(Vector64 x, Vector64 y, Vector64 amount) where T : IFloatingPointIeee754 diff --git a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs index 49c009b62d8038..3e97b7aa4f437d 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -189,6 +189,11 @@ public static void CopyTo(this System.Runtime.Intrinsics.Vector128 vector, public static System.Runtime.Intrinsics.Vector128 GreaterThan(System.Runtime.Intrinsics.Vector128 left, System.Runtime.Intrinsics.Vector128 right) { throw null; } public static System.Runtime.Intrinsics.Vector128 Hypot(System.Runtime.Intrinsics.Vector128 x, System.Runtime.Intrinsics.Vector128 y) { throw null; } public static System.Runtime.Intrinsics.Vector128 Hypot(System.Runtime.Intrinsics.Vector128 x, System.Runtime.Intrinsics.Vector128 y) { throw null; } + public static System.Runtime.Intrinsics.Vector128 IsNaN(System.Runtime.Intrinsics.Vector128 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector128 IsNegative(System.Runtime.Intrinsics.Vector128 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector128 IsPositive(System.Runtime.Intrinsics.Vector128 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector128 IsPositiveInfinity(System.Runtime.Intrinsics.Vector128 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector128 IsZero(System.Runtime.Intrinsics.Vector128 vector) { throw null; } public static System.Runtime.Intrinsics.Vector128 Lerp(System.Runtime.Intrinsics.Vector128 x, System.Runtime.Intrinsics.Vector128 y, System.Runtime.Intrinsics.Vector128 amount) { throw null; } public static System.Runtime.Intrinsics.Vector128 Lerp(System.Runtime.Intrinsics.Vector128 x, System.Runtime.Intrinsics.Vector128 y, System.Runtime.Intrinsics.Vector128 amount) { throw null; } public static bool LessThanAll(System.Runtime.Intrinsics.Vector128 left, System.Runtime.Intrinsics.Vector128 right) { throw null; } @@ -561,6 +566,11 @@ public static void CopyTo(this System.Runtime.Intrinsics.Vector256 vector, public static System.Runtime.Intrinsics.Vector256 GreaterThan(System.Runtime.Intrinsics.Vector256 left, System.Runtime.Intrinsics.Vector256 right) { throw null; } public static System.Runtime.Intrinsics.Vector256 Hypot(System.Runtime.Intrinsics.Vector256 x, System.Runtime.Intrinsics.Vector256 y) { throw null; } public static System.Runtime.Intrinsics.Vector256 Hypot(System.Runtime.Intrinsics.Vector256 x, System.Runtime.Intrinsics.Vector256 y) { throw null; } + public static System.Runtime.Intrinsics.Vector256 IsNaN(System.Runtime.Intrinsics.Vector256 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector256 IsNegative(System.Runtime.Intrinsics.Vector256 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector256 IsPositive(System.Runtime.Intrinsics.Vector256 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector256 IsPositiveInfinity(System.Runtime.Intrinsics.Vector256 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector256 IsZero(System.Runtime.Intrinsics.Vector256 vector) { throw null; } public static System.Runtime.Intrinsics.Vector256 Lerp(System.Runtime.Intrinsics.Vector256 x, System.Runtime.Intrinsics.Vector256 y, System.Runtime.Intrinsics.Vector256 amount) { throw null; } public static System.Runtime.Intrinsics.Vector256 Lerp(System.Runtime.Intrinsics.Vector256 x, System.Runtime.Intrinsics.Vector256 y, System.Runtime.Intrinsics.Vector256 amount) { throw null; } public static bool LessThanAll(System.Runtime.Intrinsics.Vector256 left, System.Runtime.Intrinsics.Vector256 right) { throw null; } @@ -934,6 +944,11 @@ public static void CopyTo(this System.Runtime.Intrinsics.Vector512 vector, public static System.Runtime.Intrinsics.Vector512 GreaterThan(System.Runtime.Intrinsics.Vector512 left, System.Runtime.Intrinsics.Vector512 right) { throw null; } public static System.Runtime.Intrinsics.Vector512 Hypot(System.Runtime.Intrinsics.Vector512 x, System.Runtime.Intrinsics.Vector512 y) { throw null; } public static System.Runtime.Intrinsics.Vector512 Hypot(System.Runtime.Intrinsics.Vector512 x, System.Runtime.Intrinsics.Vector512 y) { throw null; } + public static System.Runtime.Intrinsics.Vector512 IsNaN(System.Runtime.Intrinsics.Vector512 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector512 IsNegative(System.Runtime.Intrinsics.Vector512 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector512 IsPositive(System.Runtime.Intrinsics.Vector512 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector512 IsPositiveInfinity(System.Runtime.Intrinsics.Vector512 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector512 IsZero(System.Runtime.Intrinsics.Vector512 vector) { throw null; } public static System.Runtime.Intrinsics.Vector512 Lerp(System.Runtime.Intrinsics.Vector512 x, System.Runtime.Intrinsics.Vector512 y, System.Runtime.Intrinsics.Vector512 amount) { throw null; } public static System.Runtime.Intrinsics.Vector512 Lerp(System.Runtime.Intrinsics.Vector512 x, System.Runtime.Intrinsics.Vector512 y, System.Runtime.Intrinsics.Vector512 amount) { throw null; } public static bool LessThanAll(System.Runtime.Intrinsics.Vector512 left, System.Runtime.Intrinsics.Vector512 right) { throw null; } @@ -1276,6 +1291,11 @@ public static void CopyTo(this System.Runtime.Intrinsics.Vector64 vector, public static System.Runtime.Intrinsics.Vector64 GreaterThan(System.Runtime.Intrinsics.Vector64 left, System.Runtime.Intrinsics.Vector64 right) { throw null; } public static System.Runtime.Intrinsics.Vector64 Hypot(System.Runtime.Intrinsics.Vector64 x, System.Runtime.Intrinsics.Vector64 y) { throw null; } public static System.Runtime.Intrinsics.Vector64 Hypot(System.Runtime.Intrinsics.Vector64 x, System.Runtime.Intrinsics.Vector64 y) { throw null; } + public static System.Runtime.Intrinsics.Vector64 IsNaN(System.Runtime.Intrinsics.Vector64 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector64 IsNegative(System.Runtime.Intrinsics.Vector64 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector64 IsPositive(System.Runtime.Intrinsics.Vector64 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector64 IsPositiveInfinity(System.Runtime.Intrinsics.Vector64 vector) { throw null; } + public static System.Runtime.Intrinsics.Vector64 IsZero(System.Runtime.Intrinsics.Vector64 vector) { throw null; } public static System.Runtime.Intrinsics.Vector64 Lerp(System.Runtime.Intrinsics.Vector64 x, System.Runtime.Intrinsics.Vector64 y, System.Runtime.Intrinsics.Vector64 amount) { throw null; } public static System.Runtime.Intrinsics.Vector64 Lerp(System.Runtime.Intrinsics.Vector64 x, System.Runtime.Intrinsics.Vector64 y, System.Runtime.Intrinsics.Vector64 amount) { throw null; } public static bool LessThanAll(System.Runtime.Intrinsics.Vector64 left, System.Runtime.Intrinsics.Vector64 right) { throw null; } diff --git a/src/mono/mono/mini/simd-intrinsics.c b/src/mono/mono/mini/simd-intrinsics.c index 24393eb9b7ba90..d46bbbd8735d5a 100644 --- a/src/mono/mono/mini/simd-intrinsics.c +++ b/src/mono/mono/mini/simd-intrinsics.c @@ -1680,11 +1680,12 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi return NULL; } MonoClass *input_class = mono_class_from_mono_type_internal (fsig->params [0]); - int input_size = mono_class_value_size (vector_class, NULL); + int input_size = mono_class_value_size (input_class, NULL); if (input_size == 16) return emit_simd_ins (cfg, klass, OP_XCAST, args [0]->dreg, -1); - if (COMPILE_LLVM (cfg) && (inputSize == 8)) { - return emit_simd_ins (cfg, klass, OP_XWIDEN, args [0]->dreg, -1); + if (input_size == 8) { + if (COMPILE_LLVM (cfg)) + return emit_simd_ins (cfg, klass, OP_XWIDEN, args [0]->dreg, -1); } static float r4_0 = 0; MonoInst *zero; @@ -1706,9 +1707,10 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi return NULL; } MonoClass *input_class = mono_class_from_mono_type_internal (fsig->params [0]); - int input_size = mono_class_value_size (vector_class, NULL); - if (COMPILE_LLVM (cfg) && (inputSize == 8)) { - return emit_simd_ins (cfg, klass, OP_XWIDEN_UNSAFE, args [0]->dreg, -1); + int input_size = mono_class_value_size (input_class, NULL); + if (input_size == 8) { + if (COMPILE_LLVM (cfg)) + return emit_simd_ins (cfg, klass, OP_XWIDEN_UNSAFE, args [0]->dreg, -1); } return emit_simd_ins (cfg, klass, OP_XCAST, args [0]->dreg, -1); } @@ -2229,7 +2231,8 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi case SN_IsPositiveInfinity: { if (!is_element_type_primitive (fsig->params [0])) return NULL; - if (etype == MONO_TYPE_R4) { + MonoType *etype = get_vector_t_elem_type(fsig->params [0]); + if (etype->type == MONO_TYPE_R4) { guint32 value[4]; value [0] = 0x7F800000; @@ -2240,7 +2243,7 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi MonoInst* arg1 = emit_xconst_v128 (cfg, klass, (guint8*)value); return emit_xcompare (cfg, klass, arg0_type, args [0], arg1); } - if (etype == MONO_TYPE_R8) { + if (etype->type == MONO_TYPE_R8) { guint64 value[2]; value [0] = 0x7FF0000000000000; @@ -2822,6 +2825,7 @@ static guint16 vector_2_3_4_methods[] = { SN_Abs, SN_Add, SN_Clamp, + SN_ClampNative, SN_Conjugate, SN_CopyTo, SN_Distance, @@ -3196,9 +3200,14 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f } case SN_CopyTo: return NULL; - case SN_Clamp: { + case SN_Clamp: + case SN_ClampNative: { if (!(!fsig->hasthis && fsig->param_count == 3 && mono_metadata_type_equal (fsig->ret, type) && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type) && mono_metadata_type_equal (fsig->params [2], type))) return NULL; +#ifndef TARGET_ARM64 + if (id == SN_Clamp) + return NULL; +#endif MonoInst *max = emit_simd_ins (cfg, klass, OP_XBINOP, args[0]->dreg, args[1]->dreg); max->inst_c0 = OP_FMAX; diff --git a/src/mono/mono/mini/simd-methods.h b/src/mono/mono/mini/simd-methods.h index 6ca019068a933f..dde128d6c48262 100644 --- a/src/mono/mono/mini/simd-methods.h +++ b/src/mono/mono/mini/simd-methods.h @@ -1,5 +1,6 @@ METHOD2(".ctor", ctor) METHOD(Clamp) +METHOD(ClampNative) METHOD(Conjugate) METHOD(CopyTo) METHOD(Distance)