summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFei Peng <fei.peng@intel.com>2017-12-15 16:51:21 -0800
committerFei Peng <fei.peng@intel.com>2017-12-15 16:51:21 -0800
commit39ce8da5e02a08db5f25440a65196df369b0ffe7 (patch)
tree9cf5cfbf4b7149b77c5119bb217ea8e1a1fee5c3
parent1971e79c5be185825a23b3a1f0c7bb950c14029d (diff)
downloadcoreclr-39ce8da5e02a08db5f25440a65196df369b0ffe7.tar.gz
coreclr-39ce8da5e02a08db5f25440a65196df369b0ffe7.tar.bz2
coreclr-39ce8da5e02a08db5f25440a65196df369b0ffe7.zip
Enable Vector256<T> with AVX
-rw-r--r--src/jit/compiler.h21
-rw-r--r--src/jit/ee_il_dll.cpp6
-rw-r--r--src/jit/morph.cpp2
3 files changed, 26 insertions, 3 deletions
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index 5b47689fe9..d397239c0f 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -7705,7 +7705,8 @@ private:
// Get preferred alignment of SIMD type.
int getSIMDTypeAlignment(var_types simdType);
- // Get the number of bytes in a SIMD Vector for the current compilation.
+ // Get the number of bytes in a System.Numeric.Vector<T> for the current compilation.
+ // Note - cannot be used for System.Runtime.Intrinsic
unsigned getSIMDVectorRegisterByteLength()
{
#if defined(_TARGET_XARCH_) && !defined(LEGACY_BACKEND)
@@ -7727,9 +7728,27 @@ private:
}
// The minimum and maximum possible number of bytes in a SIMD vector.
+
+ // maxSIMDStructBytes
+ // The minimum SIMD size supported by System.Numeric.Vectors or System.Runtime.Intrinsic
+ // SSE: 16-byte Vector<T> and Vector128<T>
+ // AVX: 32-byte Vector256<T> (Vector<T> is 16-byte)
+ // AVX2: 32-byte Vector<T> and Vector256<T>
unsigned int maxSIMDStructBytes()
{
+#if FEATURE_HW_INTRINSICS && defined(_TARGET_XARCH_)
+ if (compSupports(InstructionSet_AVX))
+ {
+ return YMM_REGSIZE_BYTES;
+ }
+ else
+ {
+ assert(getSIMDSupportLevel() >= SIMD_SSE2_Supported);
+ return XMM_REGSIZE_BYTES;
+ }
+#else
return getSIMDVectorRegisterByteLength();
+#endif
}
unsigned int minSIMDStructBytes()
{
diff --git a/src/jit/ee_il_dll.cpp b/src/jit/ee_il_dll.cpp
index 45df9390df..87073760ee 100644
--- a/src/jit/ee_il_dll.cpp
+++ b/src/jit/ee_il_dll.cpp
@@ -386,7 +386,11 @@ unsigned CILJit::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
if (!jitFlags.IsSet(JitFlags::JIT_FLAG_PREJIT) && jitFlags.IsSet(JitFlags::JIT_FLAG_FEATURE_SIMD) &&
jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX2))
{
- if (JitConfig.EnableAVX() != 0)
+ if (JitConfig.EnableAVX() != 0
+#ifdef DEBUG
+ && JitConfig.EnableAVX2() != 0
+#endif
+ )
{
if (GetJitTls() != nullptr && JitTls::GetCompiler() != nullptr)
{
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 4265289ac7..88d382bb84 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -5944,7 +5944,7 @@ GenTreePtr Compiler::fgMorphArrayIndex(GenTreePtr tree)
noway_assert(elemTyp != TYP_STRUCT || elemStructType != nullptr);
#ifdef FEATURE_SIMD
- if (featureSIMD && varTypeIsStruct(elemTyp) && elemSize <= getSIMDVectorRegisterByteLength())
+ if (featureSIMD && varTypeIsStruct(elemTyp) && elemSize <= maxSIMDStructBytes())
{
// If this is a SIMD type, this is the point at which we lose the type information,
// so we need to set the correct type on the GT_IND.