Skip to content
Merged
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
5 changes: 0 additions & 5 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4741,11 +4741,6 @@ class Compiler
void getHWIntrinsicImmTypes(NamedIntrinsic intrinsic,
CORINFO_SIG_INFO* sig,
unsigned immNumber,
var_types simdBaseType,
CorInfoType simdBaseJitType,
CORINFO_CLASS_HANDLE op1ClsHnd,
CORINFO_CLASS_HANDLE op2ClsHnd,
CORINFO_CLASS_HANDLE op3ClsHnd,
unsigned* immSimdSize,
var_types* immSimdBaseType);

Expand Down
19 changes: 8 additions & 11 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,9 +2054,6 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
// If so, skip the lookup.
simdSize = (simdSize == 0) ? HWIntrinsicInfo::lookupSimdSize(this, intrinsic, sig) : simdSize;

HWIntrinsicSignatureReader sigReader;
sigReader.Read(info.compCompHnd, sig);

GenTree* immOp1 = nullptr;
GenTree* immOp2 = nullptr;
int immLowerBound = 0;
Expand All @@ -2073,8 +2070,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
{
unsigned immSimdSize = simdSize;
var_types immSimdBaseType = simdBaseType;
getHWIntrinsicImmTypes(intrinsic, sig, 2, simdBaseType, simdBaseJitType, sigReader.op1ClsHnd,
sigReader.op2ClsHnd, sigReader.op3ClsHnd, &immSimdSize, &immSimdBaseType);
getHWIntrinsicImmTypes(intrinsic, sig, 2, &immSimdSize, &immSimdBaseType);
HWIntrinsicInfo::lookupImmBounds(intrinsic, immSimdSize, immSimdBaseType, 2, &immLowerBound, &immUpperBound);

if (!CheckHWIntrinsicImmRange(intrinsic, simdBaseJitType, immOp2, mustExpand, immLowerBound, immUpperBound,
Expand Down Expand Up @@ -2121,8 +2117,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
#ifdef TARGET_ARM64
unsigned immSimdSize = simdSize;
var_types immSimdBaseType = simdBaseType;
getHWIntrinsicImmTypes(intrinsic, sig, 1, simdBaseType, simdBaseJitType, sigReader.op1ClsHnd,
sigReader.op2ClsHnd, sigReader.op3ClsHnd, &immSimdSize, &immSimdBaseType);
getHWIntrinsicImmTypes(intrinsic, sig, 1, &immSimdSize, &immSimdBaseType);
HWIntrinsicInfo::lookupImmBounds(intrinsic, immSimdSize, immSimdBaseType, 1, &immLowerBound, &immUpperBound);
#else
immUpperBound = HWIntrinsicInfo::lookupImmUpperBound(intrinsic);
Expand Down Expand Up @@ -2206,10 +2201,12 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
}
}

GenTree* op1 = nullptr;
GenTree* op2 = nullptr;
GenTree* op3 = nullptr;
GenTree* op4 = nullptr;
GenTree* op1 = nullptr;
GenTree* op2 = nullptr;
GenTree* op3 = nullptr;
GenTree* op4 = nullptr;
HWIntrinsicSignatureReader sigReader;
sigReader.Read(info.compCompHnd, sig);

switch (numArgs)
{
Expand Down
97 changes: 26 additions & 71 deletions src/coreclr/jit/hwintrinsicarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,96 +234,51 @@ void Compiler::getHWIntrinsicImmOps(NamedIntrinsic intrinsic,
// intrinsic -- NamedIntrinsic associated with the HWIntrinsic to lookup
// sig -- signature of the intrinsic call.
// immNumber -- Which immediate to use (1 for most intrinsics)
// simdBaseType -- base type of the intrinsic
// simdType -- vector size of the intrinsic
// op1ClsHnd -- cls handler for op1
// op2ClsHnd -- cls handler for op2
// op2ClsHnd -- cls handler for op3
// immSimdSize [IN/OUT] -- Size of the immediate to override
// immSimdBaseType [IN/OUT] -- Base type of the immediate to override
//
void Compiler::getHWIntrinsicImmTypes(NamedIntrinsic intrinsic,
CORINFO_SIG_INFO* sig,
unsigned immNumber,
var_types simdBaseType,
CorInfoType simdBaseJitType,
CORINFO_CLASS_HANDLE op1ClsHnd,
CORINFO_CLASS_HANDLE op2ClsHnd,
CORINFO_CLASS_HANDLE op3ClsHnd,
unsigned* immSimdSize,
var_types* immSimdBaseType)
void Compiler::getHWIntrinsicImmTypes(NamedIntrinsic intrinsic,
CORINFO_SIG_INFO* sig,
unsigned immNumber,
unsigned* immSimdSize,
var_types* immSimdBaseType)
{
HWIntrinsicCategory category = HWIntrinsicInfo::lookupCategory(intrinsic);

if (category == HW_Category_SIMDByIndexedElement)
{
assert(immNumber == 1);
*immSimdSize = 0;
CORINFO_ARG_LIST_HANDLE immArg = sig->args;

CorInfoType indexedElementBaseJitType;
var_types indexedElementBaseType;
*immSimdSize = 0;

if (sig->numArgs == 2)
{
indexedElementBaseJitType = getBaseJitTypeAndSizeOfSIMDType(op1ClsHnd, immSimdSize);
indexedElementBaseType = JitType2PreciseVarType(indexedElementBaseJitType);
}
else if (sig->numArgs == 3)
switch (sig->numArgs)
{
indexedElementBaseJitType = getBaseJitTypeAndSizeOfSIMDType(op2ClsHnd, immSimdSize);
indexedElementBaseType = JitType2PreciseVarType(indexedElementBaseJitType);
}
else
{
assert(sig->numArgs == 4);
indexedElementBaseJitType = getBaseJitTypeAndSizeOfSIMDType(op3ClsHnd, immSimdSize);
indexedElementBaseType = JitType2PreciseVarType(indexedElementBaseJitType);

if (intrinsic == NI_Dp_DotProductBySelectedQuadruplet)
{
assert(((simdBaseType == TYP_INT) && (indexedElementBaseType == TYP_BYTE)) ||
((simdBaseType == TYP_UINT) && (indexedElementBaseType == TYP_UBYTE)));
// The second source operand of sdot, udot instructions is an indexed 32-bit element.
indexedElementBaseType = simdBaseType;
}

if (intrinsic == NI_Sve_DotProductBySelectedScalar)
case 4:
immArg = info.compCompHnd->getArgNext(immArg);
FALLTHROUGH;
case 3:
immArg = info.compCompHnd->getArgNext(immArg);
FALLTHROUGH;
case 2:
{
assert(((simdBaseType == TYP_INT) && (indexedElementBaseType == TYP_BYTE)) ||
((simdBaseType == TYP_UINT) && (indexedElementBaseType == TYP_UBYTE)) ||
((simdBaseType == TYP_LONG) && (indexedElementBaseType == TYP_SHORT)) ||
((simdBaseType == TYP_ULONG) && (indexedElementBaseType == TYP_USHORT)));

// The second source operand of sdot, udot instructions is an indexed 32-bit element.
indexedElementBaseType = simdBaseType;
CORINFO_CLASS_HANDLE typeHnd = info.compCompHnd->getArgClass(sig, immArg);
getBaseJitTypeAndSizeOfSIMDType(typeHnd, immSimdSize);
break;
}
default:
unreached();
}

if (intrinsic == NI_Sve2_MultiplyBySelectedScalar ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningEven ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningEvenAndAdd ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningEvenAndSubtract ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningOdd ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningOddAndAdd ||
intrinsic == NI_Sve2_MultiplyBySelectedScalarWideningOddAndSubtract ||
intrinsic == NI_Sve2_MultiplyDoublingWideningBySelectedScalarAndAddSaturateEven ||
intrinsic == NI_Sve2_MultiplyDoublingWideningBySelectedScalarAndAddSaturateOdd ||
intrinsic == NI_Sve2_MultiplyDoublingWideningBySelectedScalarAndSubtractSaturateEven ||
intrinsic == NI_Sve2_MultiplyDoublingWideningBySelectedScalarAndSubtractSaturateOdd ||
intrinsic == NI_Sve2_MultiplySubtractBySelectedScalar)
{
indexedElementBaseType = simdBaseType;
}

assert(indexedElementBaseType == simdBaseType);
}
else if (intrinsic == NI_AdvSimd_Arm64_InsertSelectedScalar)
{
if (immNumber == 2)
{
CorInfoType otherBaseJitType = getBaseJitTypeAndSizeOfSIMDType(op3ClsHnd, immSimdSize);
*immSimdBaseType = JitType2PreciseVarType(otherBaseJitType);
assert(otherBaseJitType == simdBaseJitType);
CORINFO_ARG_LIST_HANDLE immArg = sig->args;
immArg = info.compCompHnd->getArgNext(immArg);
immArg = info.compCompHnd->getArgNext(immArg);
CORINFO_CLASS_HANDLE typeHnd = info.compCompHnd->getArgClass(sig, immArg);
CorInfoType otherBaseJitType = getBaseJitTypeAndSizeOfSIMDType(typeHnd, immSimdSize);
*immSimdBaseType = JitType2PreciseVarType(otherBaseJitType);
}
// For imm1 use default simd sizes.
}
Expand Down
30 changes: 2 additions & 28 deletions src/coreclr/jit/rationalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,30 +464,6 @@ void Rationalizer::RewriteHWIntrinsicAsUserCall(GenTree** use, ArrayStack<GenTre
break;
}

CORINFO_CLASS_HANDLE op1ClsHnd = NO_CLASS_HANDLE;
CORINFO_CLASS_HANDLE op2ClsHnd = NO_CLASS_HANDLE;
CORINFO_CLASS_HANDLE op3ClsHnd = NO_CLASS_HANDLE;

size_t argCount = operandCount - (sigInfo.hasThis() ? 1 : 0);

if (argCount > 0)
{
CORINFO_ARG_LIST_HANDLE args = sigInfo.args;
comp->info.compCompHnd->getArgType(&sigInfo, args, &op1ClsHnd);

if (argCount > 1)
{
args = comp->info.compCompHnd->getArgNext(args);
comp->info.compCompHnd->getArgType(&sigInfo, args, &op2ClsHnd);

if (argCount > 2)
{
args = comp->info.compCompHnd->getArgNext(args);
comp->info.compCompHnd->getArgType(&sigInfo, args, &op3ClsHnd);
}
}
}

// Position of the immediates from top of stack
int imm1Pos = -1;
int imm2Pos = -1;
Expand All @@ -511,8 +487,7 @@ void Rationalizer::RewriteHWIntrinsicAsUserCall(GenTree** use, ArrayStack<GenTre

if (immOp2 != nullptr)
{
comp->getHWIntrinsicImmTypes(intrinsicId, &sigInfo, 2, simdBaseType, simdBaseJitType, op1ClsHnd,
op2ClsHnd, op3ClsHnd, &immSimdSize, &immSimdBaseType);
comp->getHWIntrinsicImmTypes(intrinsicId, &sigInfo, 2, &immSimdSize, &immSimdBaseType);
HWIntrinsicInfo::lookupImmBounds(intrinsicId, immSimdSize, immSimdBaseType, 2, &immLowerBound,
&immUpperBound);

Expand All @@ -527,8 +502,7 @@ void Rationalizer::RewriteHWIntrinsicAsUserCall(GenTree** use, ArrayStack<GenTre
immSimdBaseType = simdBaseType;
}

comp->getHWIntrinsicImmTypes(intrinsicId, &sigInfo, 1, simdBaseType, simdBaseJitType, op1ClsHnd, op2ClsHnd,
op3ClsHnd, &immSimdSize, &immSimdBaseType);
comp->getHWIntrinsicImmTypes(intrinsicId, &sigInfo, 1, &immSimdSize, &immSimdBaseType);
HWIntrinsicInfo::lookupImmBounds(intrinsicId, immSimdSize, immSimdBaseType, 1, &immLowerBound,
&immUpperBound);
#endif
Expand Down
Loading