Skip to content

Commit

Permalink
Fold SIMD-typed partial access to locals; delete base types from vect…
Browse files Browse the repository at this point in the history
…or constants (dotnet#74580)

* Fold local SIMD-typed indirs

* Introduce "canonical" SIMD handles

To be used for nodes which don't have a handle of their own.

* Remove base types from GenTreeVecCon
  • Loading branch information
SingleAccretion authored Sep 26, 2022
1 parent 52e77ba commit 78443b8
Show file tree
Hide file tree
Showing 17 changed files with 172 additions and 217 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3211,7 +3211,7 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
{
simd8_t value = vnStore->ConstantValue<simd8_t>(vnCns);

GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet(), CORINFO_TYPE_FLOAT);
GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet());
vecCon->gtSimd8Val = value;

conValTree = vecCon;
Expand All @@ -3222,7 +3222,7 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
{
simd12_t value = vnStore->ConstantValue<simd12_t>(vnCns);

GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet(), CORINFO_TYPE_FLOAT);
GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet());
vecCon->gtSimd12Val = value;

conValTree = vecCon;
Expand All @@ -3233,7 +3233,7 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
{
simd16_t value = vnStore->ConstantValue<simd16_t>(vnCns);

GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet(), CORINFO_TYPE_FLOAT);
GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet());
vecCon->gtSimd16Val = value;

conValTree = vecCon;
Expand All @@ -3244,7 +3244,7 @@ GenTree* Compiler::optVNConstantPropOnTree(BasicBlock* block, GenTree* tree)
{
simd32_t value = vnStore->ConstantValue<simd32_t>(vnCns);

GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet(), CORINFO_TYPE_FLOAT);
GenTreeVecCon* vecCon = gtNewVconNode(tree->TypeGet());
vecCon->gtSimd32Val = value;

conValTree = vecCon;
Expand Down
46 changes: 43 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -2295,13 +2295,11 @@ class Compiler

GenTree* gtNewSconNode(int CPX, CORINFO_MODULE_HANDLE scpHandle);

GenTreeVecCon* gtNewVconNode(var_types type, CorInfoType simdBaseJitType);
GenTreeVecCon* gtNewVconNode(var_types type);

GenTree* gtNewAllBitsSetConNode(var_types type);
GenTree* gtNewAllBitsSetConNode(var_types type, CorInfoType simdBaseJitType);

GenTree* gtNewZeroConNode(var_types type);
GenTree* gtNewZeroConNode(var_types type, CorInfoType simdBaseJitType);

GenTree* gtNewOneConNode(var_types type);

Expand Down Expand Up @@ -8312,6 +8310,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif // defined(TARGET_XARCH)
#endif // FEATURE_HW_INTRINSICS

CORINFO_CLASS_HANDLE CanonicalSimd8Handle;
CORINFO_CLASS_HANDLE CanonicalSimd16Handle;
CORINFO_CLASS_HANDLE CanonicalSimd32Handle;

SIMDHandlesCache()
{
memset(this, 0, sizeof(*this));
Expand Down Expand Up @@ -8404,6 +8406,44 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
}
#endif // FEATURE_HW_INTRINSICS

//------------------------------------------------------------------------
// gtGetCanonicalStructHandleForSIMD: Get the "canonical" SIMD type handle.
//
// Some SIMD-typed trees do not carry struct handles with them (and in
// some cases, they cannot, due to being created by the compiler itself).
// To enable CSEing of these trees, we use "canonical" handles. These are
// captured during importation, and can represent any type normalized to
// be TYP_SIMD.
//
// Arguments:
// simdType - The SIMD type
//
// Return Value:
// The "canonical" type handle for "simdType", if one was available.
// "NO_CLASS_HANDLE" otherwise.
//
CORINFO_CLASS_HANDLE gtGetCanonicalStructHandleForSIMD(var_types simdType)
{
if (m_simdHandleCache == nullptr)
{
return NO_CLASS_HANDLE;
}

switch (simdType)
{
case TYP_SIMD8:
return m_simdHandleCache->CanonicalSimd8Handle;
case TYP_SIMD12:
return m_simdHandleCache->SIMDVector3Handle;
case TYP_SIMD16:
return m_simdHandleCache->CanonicalSimd16Handle;
case TYP_SIMD32:
return m_simdHandleCache->CanonicalSimd32Handle;
default:
unreached();
}
}

// 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
Expand Down
Loading

0 comments on commit 78443b8

Please sign in to comment.