summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarol Eidt <carol.eidt@microsoft.com>2018-12-06 13:50:19 -0800
committerGitHub <noreply@github.com>2018-12-06 13:50:19 -0800
commit61da68e56ab0b3dd4865d34aee0ca243cc702c09 (patch)
treef57e957cc3ff3fce23e16f6b4ccd1581de59371f
parent82693d8f088d2a3c0cc8e2d2f7de0a86b18b4df9 (diff)
parentf06134ed869442f28cb0ab47ef2372d539a7e5af (diff)
downloadcoreclr-61da68e56ab0b3dd4865d34aee0ca243cc702c09.tar.gz
coreclr-61da68e56ab0b3dd4865d34aee0ca243cc702c09.tar.bz2
coreclr-61da68e56ab0b3dd4865d34aee0ca243cc702c09.zip
Merge pull request #21314 from CarolEidt/DontPromoteHwVector
Don't struct-promote opaque vectors
-rw-r--r--src/jit/compiler.h26
-rw-r--r--src/jit/morph.cpp2
2 files changed, 27 insertions, 1 deletions
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index a3f46bda86..df5578f166 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -7667,6 +7667,17 @@ private:
return NO_CLASS_HANDLE;
}
+ // Returns true if this is a SIMD type that should be considered an opaque
+ // vector type (i.e. do not analyze or promote its fields).
+ // Note that all but the fixed vector types are opaque, even though they may
+ // actually be declared as having fields.
+ bool isOpaqueSIMDType(CORINFO_CLASS_HANDLE structHandle)
+ {
+ return ((m_simdHandleCache != nullptr) && (structHandle != m_simdHandleCache->SIMDVector2Handle) &&
+ (structHandle != m_simdHandleCache->SIMDVector3Handle) &&
+ (structHandle != m_simdHandleCache->SIMDVector4Handle));
+ }
+
// Returns true if the tree corresponds to a TYP_SIMD lcl var.
// Note that both SIMD vector args and locals are mared as lvSIMDType = true, but
// type of an arg node is TYP_BYREF and a local node is TYP_SIMD or TYP_STRUCT.
@@ -7675,6 +7686,16 @@ private:
return tree->OperIsLocal() && lvaTable[tree->AsLclVarCommon()->gtLclNum].lvSIMDType;
}
+ // Returns true if the lclVar is an opaque SIMD type.
+ bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
+ {
+ if (!varDsc->lvSIMDType)
+ {
+ return false;
+ }
+ return isOpaqueSIMDType(varDsc->lvVerTypeInfo.GetClassHandle());
+ }
+
// Returns true if the type of the tree is a byref of TYP_SIMD
bool isAddrOfSIMDType(GenTree* tree)
{
@@ -8014,6 +8035,11 @@ private:
return lvaSIMDInitTempVarNum;
}
+#else // !FEATURE_SIMD
+ bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
+ {
+ return false;
+ }
#endif // FEATURE_SIMD
public:
diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp
index 566714f276..164bf89507 100644
--- a/src/jit/morph.cpp
+++ b/src/jit/morph.cpp
@@ -16997,7 +16997,7 @@ void Compiler::fgPromoteStructs()
// If we have marked this as lvUsedInSIMDIntrinsic, then we do not want to promote
// its fields. Instead, we will attempt to enregister the entire struct.
- if (varDsc->lvIsSIMDType() && varDsc->lvIsUsedInSIMDIntrinsic())
+ if (varDsc->lvIsSIMDType() && (varDsc->lvIsUsedInSIMDIntrinsic() || isOpaqueSIMDLclVar(varDsc)))
{
varDsc->lvRegStruct = true;
}