Skip to content

Commit

Permalink
Fix #16236
Browse files Browse the repository at this point in the history
  • Loading branch information
FeiPengIntel committed Feb 13, 2018
1 parent 53d7ceb commit a4f5523
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 5 deletions.
19 changes: 19 additions & 0 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7634,6 +7634,25 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
return pTypeInfo->IsStruct() && isSIMDClass(pTypeInfo->GetClassHandleForValueClass());
}

bool isHWSIMDClass(CORINFO_CLASS_HANDLE clsHnd)
{
if (isIntrinsicType(clsHnd))
{
const char* namespaceName = nullptr;
(void)getClassNameFromMetadata(clsHnd, &namespaceName);
return strcmp(namespaceName, "System.Runtime.Intrinsics") == 0;
}
else
{
return false;
}
}

bool isHWSIMDClass(typeInfo* pTypeInfo)
{
return pTypeInfo->IsStruct() && isHWSIMDClass(pTypeInfo->GetClassHandleForValueClass());
}

// Get the base (element) type and size in bytes for a SIMD type. Returns TYP_UNKNOWN
// if it is not a SIMD type or is an unsupported base type.
var_types getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, unsigned* sizeBytes = nullptr);
Expand Down
24 changes: 20 additions & 4 deletions src/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18277,7 +18277,11 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
// the inlining multiplier) for anything in that assembly.
// But we only need to normalize it if it is a TYP_STRUCT
// (which we need to do even if we have already set foundSIMDType).
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && isSIMDClass(&(lclVarInfo[0].lclVerTypeInfo)))
if ((!foundSIMDType || (sigType == TYP_STRUCT)) && (isSIMDClass(&(lclVarInfo[0].lclVerTypeInfo))
#ifdef FEATURE_HW_INTRINSICS
|| isHWSIMDClass(&(lclVarInfo[0].lclVerTypeInfo))
#endif
))
{
if (sigType == TYP_STRUCT)
{
Expand Down Expand Up @@ -18344,7 +18348,11 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
lclVarInfo[i].lclVerTypeInfo = verParseArgSigToTypeInfo(&methInfo->args, argLst);

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

#ifdef FEATURE_SIMD
if ((!foundSIMDType || (type == TYP_STRUCT)) && isSIMDClass(&(lclVarInfo[i + argCnt].lclVerTypeInfo)))
if ((!foundSIMDType || (type == TYP_STRUCT)) && (isSIMDClass(&(lclVarInfo[i + argCnt].lclVerTypeInfo))
#ifdef FEATURE_HW_INTRINSICS
|| isHWSIMDClass(&(lclVarInfo[i + argCnt].lclVerTypeInfo))
#endif
))
{
foundSIMDType = true;
if (featureSIMD && type == TYP_STRUCT)
Expand All @@ -18533,7 +18545,11 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
}

#ifdef FEATURE_SIMD
if (!foundSIMDType && (call->AsCall()->gtRetClsHnd != nullptr) && isSIMDClass(call->AsCall()->gtRetClsHnd))
if (!foundSIMDType && (call->AsCall()->gtRetClsHnd != nullptr) && (isSIMDClass(call->AsCall()->gtRetClsHnd)
#ifdef FEATURE_HW_INTRINSICS
|| isHWSIMDClass(call->AsCall()->gtRetClsHnd)
#endif
))
{
foundSIMDType = true;
}
Expand Down
6 changes: 5 additions & 1 deletion src/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,11 @@ void Compiler::lvaCanPromoteStructType(CORINFO_CLASS_HANDLE typeHnd,
// Check to see if this is a SIMD type.
// We will only check this if we have already found a SIMD type, which will be true if
// we have encountered any SIMD intrinsics.
if (usesSIMDTypes() && (pFieldInfo->fldSize == 0) && isSIMDClass(pFieldInfo->fldTypeHnd))
if (usesSIMDTypes() && (pFieldInfo->fldSize == 0) && (isSIMDClass(pFieldInfo->fldTypeHnd)
#ifdef FEATURE_HW_INTRINSICS
|| isHWSIMDClass(pFieldInfo->fldTypeHnd)
#endif
))
{
unsigned simdSize;
var_types simdBaseType = getBaseTypeAndSizeOfSIMDType(pFieldInfo->fldTypeHnd, &simdSize);
Expand Down
7 changes: 7 additions & 0 deletions src/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19030,6 +19030,13 @@ Compiler::fgWalkResult Compiler::fgMarkAddrTakenLocalsPreCB(GenTree** pTree, fgW
}
else
#endif // FEATURE_SIMD
#ifdef FEATURE_HW_INTRINSICS
if (tree->gtOp.gtOp1->OperGet() == GT_HWIntrinsic)
{
axcStack->Push(AXC_None);
}
else
#endif // FEATURE_HW_INTRINSICS
if (axc == AXC_Ind)
{
axcStack->Push(AXC_None);
Expand Down

0 comments on commit a4f5523

Please sign in to comment.