diff options
author | Tanner Gooding <tagoo@outlook.com> | 2019-06-06 16:06:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-06 16:06:22 -0700 |
commit | 93216920549a0f574694e383d67d6d0ea5a4fed3 (patch) | |
tree | a2a003a7ea6be67589ed5e3c1a4ae07c21dced52 | |
parent | 4c82068adb046eee3573984392a0d1e774062ae0 (diff) | |
download | coreclr-93216920549a0f574694e383d67d6d0ea5a4fed3.tar.gz coreclr-93216920549a0f574694e383d67d6d0ea5a4fed3.tar.bz2 coreclr-93216920549a0f574694e383d67d6d0ea5a4fed3.zip |
Marking Vector128<T>.Count and Vector256<T>.Count as [Intrinsic] (#24991)
* Marking Vector128<T>.Count and Vector256<T>.Count as [Intrinsic]
* Fixing NI_Vector128_Count and NI_Vector256_Count to use clsHnd when getting the simdSize and baseType
* Applying the formatting patch.
* Changing some comments to just be "vector element count".
* Fixing impBaseIntrinsic to set the baseType so Vector128_Count and Vector256_Count don't return nullptr
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs | 1 | ||||
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs | 1 | ||||
-rw-r--r-- | src/jit/compiler.h | 4 | ||||
-rw-r--r-- | src/jit/gentree.cpp | 2 | ||||
-rw-r--r-- | src/jit/hwintrinsicArm64.cpp | 1 | ||||
-rw-r--r-- | src/jit/hwintrinsiclistxarch.h | 2 | ||||
-rw-r--r-- | src/jit/hwintrinsicxarch.cpp | 22 | ||||
-rw-r--r-- | src/jit/importer.cpp | 2 | ||||
-rw-r--r-- | src/jit/optimizer.cpp | 2 |
9 files changed, 30 insertions, 7 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs index cdcddcb49e..9f609eabe4 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128_1.cs @@ -39,6 +39,7 @@ namespace System.Runtime.Intrinsics /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> public static int Count { + [Intrinsic] get { ThrowHelper.ThrowForUnsupportedVectorBaseType<T>(); diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs index 2ed5516455..0a9b99347b 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256_1.cs @@ -41,6 +41,7 @@ namespace System.Runtime.Intrinsics /// <exception cref="NotSupportedException">The type of the current instance (<typeparamref name="T" />) is not supported.</exception> public static int Count { + [Intrinsic] get { ThrowHelper.ThrowForUnsupportedVectorBaseType<T>(); diff --git a/src/jit/compiler.h b/src/jit/compiler.h index c73ca30c16..da42aa14ce 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -3527,6 +3527,7 @@ protected: #ifdef FEATURE_HW_INTRINSICS GenTree* impHWIntrinsic(NamedIntrinsic intrinsic, + CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); @@ -3540,6 +3541,7 @@ protected: #ifdef _TARGET_XARCH_ GenTree* impBaseIntrinsic(NamedIntrinsic intrinsic, + CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand); @@ -5770,7 +5772,7 @@ public: #define LPFLG_VAR_LIMIT 0x0100 // iterator is compared with a local var (var # found in lpVarLimit) #define LPFLG_CONST_LIMIT 0x0200 // iterator is compared with a constant (found in lpConstLimit) #define LPFLG_ARRLEN_LIMIT 0x0400 // iterator is compared with a.len or a[i].len (found in lpArrLenLimit) -#define LPFLG_SIMD_LIMIT 0x0080 // iterator is compared with Vector<T>.Count (found in lpConstLimit) +#define LPFLG_SIMD_LIMIT 0x0080 // iterator is compared with vector element count (found in lpConstLimit) #define LPFLG_HAS_PREHEAD 0x0800 // lpHead is known to be a preHead for this loop #define LPFLG_REMOVED 0x1000 // has been removed from the loop table (unrolled or optimized away) diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index a6bbf8152b..df2bdfef06 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -10196,7 +10196,7 @@ void Compiler::gtDispConst(GenTree* tree) #ifdef FEATURE_SIMD if ((tree->gtFlags & GTF_ICON_SIMD_COUNT) != 0) { - printf(" Vector<T>.Count"); + printf(" vector element count"); } #endif diff --git a/src/jit/hwintrinsicArm64.cpp b/src/jit/hwintrinsicArm64.cpp index dec60383bd..1cd9024e88 100644 --- a/src/jit/hwintrinsicArm64.cpp +++ b/src/jit/hwintrinsicArm64.cpp @@ -321,6 +321,7 @@ int HWIntrinsicInfo::lookupNumArgs(const GenTreeHWIntrinsic* node) // the expanded intrinsic. // GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, + CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand) diff --git a/src/jit/hwintrinsiclistxarch.h b/src/jit/hwintrinsiclistxarch.h index 447d401f25..c00a92e21c 100644 --- a/src/jit/hwintrinsiclistxarch.h +++ b/src/jit/hwintrinsiclistxarch.h @@ -38,6 +38,7 @@ HARDWARE_INTRINSIC(Vector128_AsSingle, "AsSingle", HARDWARE_INTRINSIC(Vector128_AsUInt16, "AsUInt16", Vector128, -1, 16, 1, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128_AsUInt32, "AsUInt32", Vector128, -1, 16, 1, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128_AsUInt64, "AsUInt64", Vector128, -1, 16, 1, {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_NoRMWSemantics) +HARDWARE_INTRINSIC(Vector128_Count, "get_Count", Vector128, -1, 16, 0, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128_CreateScalarUnsafe, "CreateScalarUnsafe", Vector128, -1, 16, 1, {INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_movss, INS_movsdsse2}, HW_Category_SIMDScalar, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(Vector128_GetElement, "GetElement", Vector128, -1, 16, 2, {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_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector128_WithElement, "WithElement", Vector128, -1, 16, 3, {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_BaseTypeFromFirstArg) @@ -62,6 +63,7 @@ HARDWARE_INTRINSIC(Vector256_AsSingle, "AsSingle", HARDWARE_INTRINSIC(Vector256_AsUInt16, "AsUInt16", Vector256, -1, 32, 1, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector256_AsUInt32, "AsUInt32", Vector256, -1, 32, 1, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector256_AsUInt64, "AsUInt64", Vector256, -1, 32, 1, {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_NoRMWSemantics) +HARDWARE_INTRINSIC(Vector256_Count, "get_Count", Vector256, -1, 32, 0, {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_NoRMWSemantics) HARDWARE_INTRINSIC(Vector256_CreateScalarUnsafe, "CreateScalarUnsafe", Vector256, -1, 32, 1, {INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_mov_i2xmm, INS_movss, INS_movsdsse2}, HW_Category_SIMDScalar, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(Vector256_GetElement, "GetElement", Vector256, -1, 32, 2, {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_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(Vector256_WithElement, "WithElement", Vector256, -1, 32, 3, {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_BaseTypeFromFirstArg) diff --git a/src/jit/hwintrinsicxarch.cpp b/src/jit/hwintrinsicxarch.cpp index 7835454e70..3b0c6f8ef0 100644 --- a/src/jit/hwintrinsicxarch.cpp +++ b/src/jit/hwintrinsicxarch.cpp @@ -757,6 +757,7 @@ static bool impIsTableDrivenHWIntrinsic(NamedIntrinsic intrinsicId, HWIntrinsicC // the expanded intrinsic. // GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, + CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand) @@ -954,7 +955,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, { case InstructionSet_Vector128: case InstructionSet_Vector256: - return impBaseIntrinsic(intrinsic, method, sig, mustExpand); + return impBaseIntrinsic(intrinsic, clsHnd, method, sig, mustExpand); case InstructionSet_SSE: return impSSEIntrinsic(intrinsic, method, sig, mustExpand); case InstructionSet_SSE2: @@ -1002,6 +1003,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic, // the expanded intrinsic. // GenTree* Compiler::impBaseIntrinsic(NamedIntrinsic intrinsic, + CORINFO_CLASS_HANDLE clsHnd, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig, bool mustExpand) @@ -1035,12 +1037,15 @@ GenTree* Compiler::impBaseIntrinsic(NamedIntrinsic intrinsic, retType = getSIMDTypeForSize(retSimdSize); } } - else + else if (retType == TYP_STRUCT) { - assert(retType == TYP_STRUCT); baseType = getBaseTypeAndSizeOfSIMDType(sig->retTypeClass, &simdSize); retType = getSIMDTypeForSize(simdSize); } + else + { + baseType = getBaseTypeAndSizeOfSIMDType(clsHnd, &simdSize); + } if (!varTypeIsArithmetic(baseType)) { @@ -1094,6 +1099,17 @@ GenTree* Compiler::impBaseIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_Vector128_Count: + case NI_Vector256_Count: + { + assert(sig->numArgs == 0); + + GenTreeIntCon* countNode = gtNewIconNode(getSIMDVectorLength(simdSize, baseType), TYP_INT); + countNode->gtFlags |= GTF_ICON_SIMD_COUNT; + retNode = countNode; + break; + } + case NI_Vector128_CreateScalarUnsafe: { assert(sig->numArgs == 1); diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 993889d0db..83942d6005 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -3500,7 +3500,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, if ((ni > NI_HW_INTRINSIC_START) && (ni < NI_HW_INTRINSIC_END)) { - GenTree* hwintrinsic = impHWIntrinsic(ni, method, sig, mustExpand); + GenTree* hwintrinsic = impHWIntrinsic(ni, clsHnd, method, sig, mustExpand); if (mustExpand && (hwintrinsic == nullptr)) { diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp index 7749e928ba..00e518a890 100644 --- a/src/jit/optimizer.cpp +++ b/src/jit/optimizer.cpp @@ -3553,7 +3553,7 @@ void Compiler::optUnrollLoops() if (compStressCompile(STRESS_UNROLL_LOOPS, 50)) { // In stress mode, quadruple the size limit, and drop - // the restriction that loop limit must be Vector<T>.Count. + // the restriction that loop limit must be vector element count. unrollLimitSz *= 4; requiredFlags &= ~LPFLG_SIMD_LIMIT; |