Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 6 additions & 100 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ class LclVarDsc
unsigned char lvLRACandidate : 1; // Tracked for linear scan register allocation purposes

#ifdef FEATURE_SIMD
unsigned char lvUsedInSIMDIntrinsic : 1; // This tells lclvar is used for simd intrinsic
#endif // FEATURE_SIMD
unsigned char lvIsBitcastToSimd : 1; // This tracks whether the lclvar was bitcast to a simd type
#endif // FEATURE_SIMD

unsigned char lvRegStruct : 1; // This is a reg-sized non-field-addressed struct.

Expand Down Expand Up @@ -833,13 +833,13 @@ class LclVarDsc
/////////////////////

#ifdef FEATURE_SIMD
// Is this is a SIMD struct which is used for SIMD intrinsic?
bool lvIsUsedInSIMDIntrinsic() const
// Is this a TY_STRUCT which is bitcast to a TYP_SIMD
bool IsBitcastToSimd() const
Comment thread
tannergooding marked this conversation as resolved.
{
return lvUsedInSIMDIntrinsic;
return lvIsBitcastToSimd;
}
#else
bool lvIsUsedInSIMDIntrinsic() const
bool IsBitcastToSimd() const
{
return false;
}
Expand Down Expand Up @@ -3363,10 +3363,6 @@ class Compiler

GenTreeFieldList* gtNewFieldList();

#ifdef FEATURE_SIMD
void SetOpLclRelatedToSIMDIntrinsic(GenTree* op);
#endif

#ifdef FEATURE_HW_INTRINSICS
GenTreeHWIntrinsic* gtNewSimdHWIntrinsicNode(var_types type,
NamedIntrinsic hwIntrinsicID,
Expand Down Expand Up @@ -10040,90 +10036,6 @@ class Compiler
// by the hardware. It is allocated when/if such situations are encountered during Lowering.
unsigned lvaSIMDInitTempVarNum = BAD_VAR_NUM;

struct SIMDHandlesCache
{
CORINFO_CLASS_HANDLE PlaneHandle;
CORINFO_CLASS_HANDLE QuaternionHandle;
CORINFO_CLASS_HANDLE Vector2Handle;
CORINFO_CLASS_HANDLE Vector3Handle;
CORINFO_CLASS_HANDLE Vector4Handle;
CORINFO_CLASS_HANDLE VectorHandle;

SIMDHandlesCache()
{
memset(this, 0, sizeof(*this));
}
};

SIMDHandlesCache* m_simdHandleCache = nullptr;

// 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) const
{
// We order the checks roughly by expected hit count so early exits are possible

if (m_simdHandleCache == nullptr)
{
return false;
}

if (structHandle == m_simdHandleCache->Vector4Handle)
{
return false;
}

if (structHandle == m_simdHandleCache->Vector3Handle)
{
return false;
}

if (structHandle == m_simdHandleCache->Vector2Handle)
{
return false;
}

if (structHandle == m_simdHandleCache->QuaternionHandle)
{
return false;
}

if (structHandle == m_simdHandleCache->PlaneHandle)
{
return false;
}

return true;
}

bool isOpaqueSIMDType(ClassLayout* layout) const
{
if (layout->IsCustomLayout())
{
return true;
}

return isOpaqueSIMDType(layout->GetClassHandle());
}

// Returns true if the lclVar is an opaque SIMD type.
bool isOpaqueSIMDLclVar(const LclVarDsc* varDsc) const
{
if (!varTypeIsSIMD(varDsc))
{
return false;
}

if (varDsc->GetLayout() == nullptr)
{
return true;
}

return isOpaqueSIMDType(varDsc->GetLayout());
}

bool isSystemHalfClass(CORINFO_CLASS_HANDLE clsHnd)
{
if (isIntrinsicType(clsHnd))
Expand Down Expand Up @@ -10177,8 +10089,6 @@ class Compiler

GenTree* impSIMDPopStack();

void setLclRelatedToSIMDIntrinsic(GenTree* tree);

// Get the size of the SIMD type in bytes
int getSIMDTypeSizeInBytes(CORINFO_CLASS_HANDLE typeHnd)
{
Expand Down Expand Up @@ -10436,10 +10346,6 @@ class Compiler
unsigned getSIMDInitTempVarNum(var_types simdType);

#else // !FEATURE_SIMD
bool isOpaqueSIMDLclVar(LclVarDsc* varDsc)
{
return false;
}
unsigned int roundUpSIMDSize(unsigned size)
{
return 0;
Expand Down
71 changes: 5 additions & 66 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10064,8 +10064,7 @@ GenTreeFieldAddr* Compiler::gtNewFieldAddrNode(var_types type, CORINFO_FIELD_HAN
//------------------------------------------------------------------------
// gtInitializeStoreNode: Initialize a store node.
//
// Common initialization for all STORE nodes. Marks SIMD locals as "used in
// a HW intrinsic".
// Common initialization for all STORE nodes.
//
// Arguments:
// store - The store node
Expand All @@ -10075,21 +10074,6 @@ void Compiler::gtInitializeStoreNode(GenTree* store, GenTree* value)
{
// TODO-ASG: add asserts that the types match here.
assert(store->Data() == value);

#if defined(FEATURE_SIMD)
if (varTypeIsSIMDOrMask(store))
{
// TODO-ASG: delete this zero-diff quirk.
if (!value->IsCall() || !value->AsCall()->ShouldHaveRetBufArg())
{
// We want to track SIMD/Mask stores as being intrinsics since they
// are functionally `mov` instructions and are more efficient when
// we don't promote, particularly when it occurs due to inlining.
SetOpLclRelatedToSIMDIntrinsic(store);
SetOpLclRelatedToSIMDIntrinsic(value);
}
}
#endif // FEATURE_SIMD
}

Comment thread
tannergooding marked this conversation as resolved.
//------------------------------------------------------------------------
Expand Down Expand Up @@ -21884,21 +21868,6 @@ FieldSeq::FieldSeq(CORINFO_FIELD_HANDLE fieldHnd, ssize_t offset, FieldKind fiel
}

#ifdef FEATURE_SIMD
//-------------------------------------------------------------------
// SetOpLclRelatedToSIMDIntrinsic: Determine if the tree has a local var that needs to be set
// as used by a SIMD intrinsic, and if so, set that local var appropriately.
//
// Arguments:
// op - The tree, to be an operand of a new SIMD-related node, to check.
//
void Compiler::SetOpLclRelatedToSIMDIntrinsic(GenTree* op)
{
if ((op != nullptr) && op->OperIsScalarLocal())
{
setLclRelatedToSIMDIntrinsic(op);
}
}

void GenTreeMultiOp::ResetOperandArray(size_t newOperandCount,
Compiler* compiler,
GenTree** inlineOperands,
Expand Down Expand Up @@ -22679,18 +22648,13 @@ GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(var_types type,
GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(
var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID, var_types simdBaseType, unsigned simdSize)
{
SetOpLclRelatedToSIMDIntrinsic(op1);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, simdBaseType, simdSize, op1);
}

GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(
var_types type, GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID, var_types simdBaseType, unsigned simdSize)
{
SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, simdBaseType, simdSize, op1, op2);
}
Expand All @@ -22703,10 +22667,6 @@ GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(var_types type,
var_types simdBaseType,
unsigned simdSize)
{
SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);
SetOpLclRelatedToSIMDIntrinsic(op3);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, simdBaseType, simdSize, op1, op2, op3);
}
Expand All @@ -22720,11 +22680,6 @@ GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(var_types type,
var_types simdBaseType,
unsigned simdSize)
{
SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);
SetOpLclRelatedToSIMDIntrinsic(op3);
SetOpLclRelatedToSIMDIntrinsic(op4);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, simdBaseType, simdSize, op1, op2, op3, op4);
}
Expand All @@ -22740,7 +22695,6 @@ GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(var_types type,
for (size_t i = 0; i < operandCount; i++)
{
nodeBuilder.AddOperand(i, operands[i]);
SetOpLclRelatedToSIMDIntrinsic(operands[i]);
}

return new (this, GT_HWINTRINSIC)
Expand All @@ -22753,11 +22707,6 @@ GenTreeHWIntrinsic* Compiler::gtNewSimdHWIntrinsicNode(var_types ty
var_types simdBaseType,
unsigned simdSize)
{
for (size_t i = 0; i < nodeBuilder.GetOperandCount(); i++)
{
SetOpLclRelatedToSIMDIntrinsic(nodeBuilder.GetOperand(i));
}

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, std::move(nodeBuilder), hwIntrinsicID, simdBaseType, simdSize);
}
Expand Down Expand Up @@ -25815,10 +25764,9 @@ GenTree* Compiler::gtNewSimdLoadNode(var_types type, GenTree* op1, var_types sim
assert(getSIMDTypeForSize(simdSize) == type);

assert(op1 != nullptr);

assert(varTypeIsArithmetic(simdBaseType));

return gtNewIndir(type, op1);
return gtNewLoadValueNode(type, op1);
}

//----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -28540,12 +28488,12 @@ GenTree* Compiler::gtNewSimdStoreNode(GenTree* op1, GenTree* op2, var_types simd
assert(op1 != nullptr);
assert(op2 != nullptr);

assert(varTypeIsArithmetic(simdBaseType));

assert(varTypeIsSIMD(op2));
assert(getSIMDTypeForSize(simdSize) == op2->TypeGet());

assert(varTypeIsArithmetic(simdBaseType));

return gtNewStoreIndNode(op2->TypeGet(), op1, op2);
return gtNewStoreValueNode(op2->TypeGet(), op1, op2);
}

//----------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -29781,8 +29729,6 @@ GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type, NamedIn

GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type, GenTree* op1, NamedIntrinsic hwIntrinsicID)
{
SetOpLclRelatedToSIMDIntrinsic(op1);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, TYP_UNKNOWN, 0, op1);
}
Expand All @@ -29792,20 +29738,13 @@ GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type,
GenTree* op2,
NamedIntrinsic hwIntrinsicID)
{
SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, TYP_UNKNOWN, 0, op1, op2);
}

GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(
var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID)
{
SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);
SetOpLclRelatedToSIMDIntrinsic(op3);

return new (this, GT_HWINTRINSIC)
GenTreeHWIntrinsic(type, getAllocator(CMK_ASTNode), hwIntrinsicID, TYP_UNKNOWN, 0, op1, op2, op3);
}
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/jit/hwintrinsicarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
// and the signature return type are both the same TYP_SIMD.

retNode = impSIMDPopStack();
SetOpLclRelatedToSIMDIntrinsic(retNode);
assert(retNode->gtType == getSIMDTypeForSize(getSIMDTypeSizeInBytes(sig->retTypeSigClass)));
break;
}
Expand Down Expand Up @@ -939,7 +938,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
// and the signature return type are both the same TYP_SIMD.

retNode = impSIMDPopStack();
SetOpLclRelatedToSIMDIntrinsic(retNode);
assert(retNode->gtType == getSIMDTypeForSize(getSIMDTypeSizeInBytes(sig->retTypeSigClass)));
break;
}
Expand Down Expand Up @@ -3421,11 +3419,6 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
argType = JITtype2varType(strip(info.compCompHnd->getArgType(sig, arg1, &argClass)));
op1 = getArgForHWIntrinsic(argType, argClass);

SetOpLclRelatedToSIMDIntrinsic(op1);
SetOpLclRelatedToSIMDIntrinsic(op2);
SetOpLclRelatedToSIMDIntrinsic(op3);
SetOpLclRelatedToSIMDIntrinsic(op4);
SetOpLclRelatedToSIMDIntrinsic(op5);
retNode = new (this, GT_HWINTRINSIC) GenTreeHWIntrinsic(retType, getAllocator(CMK_ASTNode), intrinsic,
simdBaseType, simdSize, op1, op2, op3, op4, op5);
break;
Expand Down
Loading
Loading