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

Commit 1581ae2

Browse files
FeiPengInteltannergooding
authored andcommitted
Fix importer and morph with HWIntrinsic SIMD types
1 parent 9726fd2 commit 1581ae2

File tree

4 files changed

+44
-5
lines changed

4 files changed

+44
-5
lines changed

src/jit/compiler.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7681,6 +7681,38 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
76817681
return pTypeInfo->IsStruct() && isSIMDClass(pTypeInfo->GetClassHandleForValueClass());
76827682
}
76837683

7684+
bool isHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd)
7685+
{
7686+
#ifdef FEATURE_HW_INTRINSICS
7687+
if (isIntrinsicType(clsHnd))
7688+
{
7689+
const char* namespaceName = nullptr;
7690+
(void)getClassNameFromMetadata(clsHnd, &namespaceName);
7691+
return strcmp(namespaceName, "System.Runtime.Intrinsics") == 0;
7692+
}
7693+
#endif // FEATURE_HW_INTRINSICS
7694+
return false;
7695+
}
7696+
7697+
bool isHWSIMDClass(typeInfo* pTypeInfo)
7698+
{
7699+
#ifdef FEATURE_HW_INTRINSICS
7700+
return pTypeInfo->IsStruct() && isHWSIMDClass(pTypeInfo->GetClassHandleForValueClass());
7701+
#else
7702+
return false;
7703+
#endif
7704+
}
7705+
7706+
bool isSIMDorHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd)
7707+
{
7708+
return isSIMDClass(clsHnd) || isHWSIMDClass(clsHnd);
7709+
}
7710+
7711+
bool isSIMDorHWSIMDClass(typeInfo* pTypeInfo)
7712+
{
7713+
return isSIMDClass(pTypeInfo) || isHWSIMDClass(pTypeInfo);
7714+
}
7715+
76847716
// Get the base (element) type and size in bytes for a SIMD type. Returns TYP_UNKNOWN
76857717
// if it is not a SIMD type or is an unsupported base type.
76867718
var_types getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, unsigned* sizeBytes = nullptr);

src/jit/importer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18277,7 +18277,7 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
1827718277
// the inlining multiplier) for anything in that assembly.
1827818278
// But we only need to normalize it if it is a TYP_STRUCT
1827918279
// (which we need to do even if we have already set foundSIMDType).
18280-
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && isSIMDClass(&(lclVarInfo[0].lclVerTypeInfo)))
18280+
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && isSIMDorHWSIMDClass(&(lclVarInfo[0].lclVerTypeInfo)))
1828118281
{
1828218282
if (sigType == TYP_STRUCT)
1828318283
{
@@ -18344,7 +18344,7 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
1834418344
lclVarInfo[i].lclVerTypeInfo = verParseArgSigToTypeInfo(&methInfo->args, argLst);
1834518345

1834618346
#ifdef FEATURE_SIMD
18347-
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && isSIMDClass(&(lclVarInfo[i].lclVerTypeInfo)))
18347+
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && isSIMDorHWSIMDClass(&(lclVarInfo[i].lclVerTypeInfo)))
1834818348
{
1834918349
// If this is a SIMD class (i.e. in the SIMD assembly), then we will consider that we've
1835018350
// found a SIMD type, even if this may not be a type we recognize (the assumption is that
@@ -18520,7 +18520,7 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
1852018520
localsSig = info.compCompHnd->getArgNext(localsSig);
1852118521

1852218522
#ifdef FEATURE_SIMD
18523-
if ((!foundSIMDType || (type == TYP_STRUCT)) && isSIMDClass(&(lclVarInfo[i + argCnt].lclVerTypeInfo)))
18523+
if ((!foundSIMDType || (type == TYP_STRUCT)) && isSIMDorHWSIMDClass(&(lclVarInfo[i + argCnt].lclVerTypeInfo)))
1852418524
{
1852518525
foundSIMDType = true;
1852618526
if (featureSIMD && type == TYP_STRUCT)
@@ -18533,7 +18533,7 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
1853318533
}
1853418534

1853518535
#ifdef FEATURE_SIMD
18536-
if (!foundSIMDType && (call->AsCall()->gtRetClsHnd != nullptr) && isSIMDClass(call->AsCall()->gtRetClsHnd))
18536+
if (!foundSIMDType && (call->AsCall()->gtRetClsHnd != nullptr) && isSIMDorHWSIMDClass(call->AsCall()->gtRetClsHnd))
1853718537
{
1853818538
foundSIMDType = true;
1853918539
}

src/jit/lclvars.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ void Compiler::lvaCanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd,
15641564
// Check to see if this is a SIMD type.
15651565
// We will only check this if we have already found a SIMD type, which will be true if
15661566
// we have encountered any SIMD intrinsics.
1567-
if (usesSIMDTypes() && (pFieldInfo->fldSize == 0) && isSIMDClass(pFieldInfo->fldTypeHnd))
1567+
if (usesSIMDTypes() && (pFieldInfo->fldSize == 0) && isSIMDorHWSIMDClass(pFieldInfo->fldTypeHnd))
15681568
{
15691569
unsigned simdSize;
15701570
var_types simdBaseType = getBaseTypeAndSizeOfSIMDType(pFieldInfo->fldTypeHnd, &simdSize);

src/jit/morph.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19042,6 +19042,13 @@ Compiler::fgWalkResult Compiler::fgMarkAddrTakenLocalsPreCB(GenTree** pTree, fgW
1904219042
}
1904319043
else
1904419044
#endif // FEATURE_SIMD
19045+
#ifdef FEATURE_HW_INTRINSICS
19046+
if (tree->gtOp.gtOp1->OperIsSimdHWIntrinsic())
19047+
{
19048+
axcStack->Push(AXC_None);
19049+
}
19050+
else
19051+
#endif // FEATURE_HW_INTRINSICS
1904519052
if (axc == AXC_Ind)
1904619053
{
1904719054
axcStack->Push(AXC_None);

0 commit comments

Comments
 (0)