From d7042a684f0cc602490f9a5cb9bffe39df782e31 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 4 Jun 2020 15:26:33 -0700 Subject: [PATCH 1/2] Ensure the right SIMD size is used for the AsVector256 AVX code --- src/coreclr/src/jit/hwintrinsicxarch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/src/jit/hwintrinsicxarch.cpp b/src/coreclr/src/jit/hwintrinsicxarch.cpp index f1b7fa94317a10..9cbd3e13aeb22e 100644 --- a/src/coreclr/src/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/src/jit/hwintrinsicxarch.cpp @@ -707,7 +707,7 @@ GenTree* Compiler::impBaseIntrinsic(NamedIntrinsic intrinsic, else { assert(intrinsic == NI_Vector256_AsVector256); - return impBaseIntrinsic(NI_Vector128_ToVector256, clsHnd, method, sig, baseType, retType, simdSize); + return impBaseIntrinsic(NI_Vector128_ToVector256, clsHnd, method, sig, baseType, retType, 16); } } From dccf38d15d80dc648aae6db9592b4aff23d7cb64 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 8 Jun 2020 10:04:03 -0700 Subject: [PATCH 2/2] Don't create GT_SIMD nodes if the baseline ISAs are not supported. --- src/coreclr/src/jit/simd.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/coreclr/src/jit/simd.cpp b/src/coreclr/src/jit/simd.cpp index 3bd38ef537199c..6b86f8c1b0c59b 100644 --- a/src/coreclr/src/jit/simd.cpp +++ b/src/coreclr/src/jit/simd.cpp @@ -1824,6 +1824,25 @@ GenTree* Compiler::impSIMDIntrinsic(OPCODE opcode, return nullptr; } +#if defined(TARGET_XARCH) + CORINFO_InstructionSet minimumIsa = InstructionSet_SSE2; +#elif defined(TARGET_ARM64) + CORINFO_InstructionSet minimumIsa = InstructionSet_AdvSimd; +#else +#error Unsupported platform +#endif // !TARGET_XARCH && !TARGET_ARM64 + + if (!compOpportunisticallyDependsOn(minimumIsa)) + { + // The user disabled support for the baseline ISA so + // don't emit any SIMD intrinsics as they all require + // this at a minimum. We will, however, return false + // for IsHardwareAccelerated as that will help with + // dead code elimination. + + return (intrinsicInfo->id == SIMDIntrinsicHWAccel) ? gtNewIconNode(0, TYP_INT) : nullptr; + } + SIMDIntrinsicID simdIntrinsicID = intrinsicInfo->id; var_types simdType; if (baseType != TYP_UNKNOWN)