Skip to content

Commit

Permalink
Merge pull request dotnet/coreclr#21314 from CarolEidt/DontPromoteHwV…
Browse files Browse the repository at this point in the history
…ector

Don't struct-promote opaque vectors

Commit migrated from dotnet/coreclr@61da68e
  • Loading branch information
CarolEidt authored Dec 6, 2018
2 parents cb30ff3 + cbd3fb3 commit 9862599
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/coreclr/src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7667,6 +7667,17 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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.
Expand All @@ -7675,6 +7686,16 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
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)
{
Expand Down Expand Up @@ -8014,6 +8035,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return lvaSIMDInitTempVarNum;
}

#else // !FEATURE_SIMD
bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
{
return false;
}
#endif // FEATURE_SIMD

public:
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9862599

Please sign in to comment.