Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 61da68e

Browse files
authored
Merge pull request #21314 from CarolEidt/DontPromoteHwVector
Don't struct-promote opaque vectors
2 parents 82693d8 + f06134e commit 61da68e

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/jit/compiler.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7667,6 +7667,17 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
76677667
return NO_CLASS_HANDLE;
76687668
}
76697669

7670+
// Returns true if this is a SIMD type that should be considered an opaque
7671+
// vector type (i.e. do not analyze or promote its fields).
7672+
// Note that all but the fixed vector types are opaque, even though they may
7673+
// actually be declared as having fields.
7674+
bool isOpaqueSIMDType(CORINFO_CLASS_HANDLE structHandle)
7675+
{
7676+
return ((m_simdHandleCache != nullptr) && (structHandle != m_simdHandleCache->SIMDVector2Handle) &&
7677+
(structHandle != m_simdHandleCache->SIMDVector3Handle) &&
7678+
(structHandle != m_simdHandleCache->SIMDVector4Handle));
7679+
}
7680+
76707681
// Returns true if the tree corresponds to a TYP_SIMD lcl var.
76717682
// Note that both SIMD vector args and locals are mared as lvSIMDType = true, but
76727683
// type of an arg node is TYP_BYREF and a local node is TYP_SIMD or TYP_STRUCT.
@@ -7675,6 +7686,16 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
76757686
return tree->OperIsLocal() && lvaTable[tree->AsLclVarCommon()->gtLclNum].lvSIMDType;
76767687
}
76777688

7689+
// Returns true if the lclVar is an opaque SIMD type.
7690+
bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
7691+
{
7692+
if (!varDsc->lvSIMDType)
7693+
{
7694+
return false;
7695+
}
7696+
return isOpaqueSIMDType(varDsc->lvVerTypeInfo.GetClassHandle());
7697+
}
7698+
76787699
// Returns true if the type of the tree is a byref of TYP_SIMD
76797700
bool isAddrOfSIMDType(GenTree* tree)
76807701
{
@@ -8014,6 +8035,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
80148035
return lvaSIMDInitTempVarNum;
80158036
}
80168037

8038+
#else // !FEATURE_SIMD
8039+
bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
8040+
{
8041+
return false;
8042+
}
80178043
#endif // FEATURE_SIMD
80188044

80198045
public:

src/jit/morph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16997,7 +16997,7 @@ void Compiler::fgPromoteStructs()
1699716997

1699816998
// If we have marked this as lvUsedInSIMDIntrinsic, then we do not want to promote
1699916999
// its fields. Instead, we will attempt to enregister the entire struct.
17000-
if (varDsc->lvIsSIMDType() && varDsc->lvIsUsedInSIMDIntrinsic())
17000+
if (varDsc->lvIsSIMDType() && (varDsc->lvIsUsedInSIMDIntrinsic() || isOpaqueSIMDLclVar(varDsc)))
1700117001
{
1700217002
varDsc->lvRegStruct = true;
1700317003
}

0 commit comments

Comments
 (0)