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

Commit 224b8dc

Browse files
committed
Adding support for the SSE StaticCast intrinsic
1 parent 9e54585 commit 224b8dc

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

src/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node)
448448
emit->emitIns_SIMD_R_R(INS_sqrtps, targetReg, op1Reg, TYP_SIMD16);
449449
break;
450450

451+
case NI_SSE_StaticCast:
452+
assert(op2 == nullptr);
453+
if (op1Reg != targetReg)
454+
{
455+
emit->emitIns_SIMD_R_R(INS_movaps, targetReg, op1Reg, TYP_SIMD16);
456+
}
457+
break;
458+
451459
case NI_SSE_Subtract:
452460
assert(baseType == TYP_FLOAT);
453461
op2Reg = op2->gtRegNum;

src/jit/hwintrinsicxarch.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ extern const char* getHWIntrinsicName(NamedIntrinsic intrinsic)
2323
return hwIntrinsicInfoArray[intrinsic - NI_HW_INTRINSIC_START - 1].intrinsicName;
2424
}
2525

26+
static const bool isNumericType(var_types type)
27+
{
28+
switch (type)
29+
{
30+
case TYP_BYTE:
31+
case TYP_UBYTE:
32+
case TYP_SHORT:
33+
case TYP_USHORT:
34+
case TYP_INT:
35+
case TYP_UINT:
36+
case TYP_LONG:
37+
case TYP_ULONG:
38+
case TYP_FLOAT:
39+
case TYP_DOUBLE:
40+
return true;
41+
42+
default:
43+
return false;
44+
}
45+
}
46+
2647
//------------------------------------------------------------------------
2748
// lookupHWIntrinsicISA: map class name to InstructionSet value
2849
//
@@ -474,6 +495,7 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic,
474495
}
475496

476497
case NI_SSE_Shuffle:
498+
{
477499
assert(sig->numArgs == 3);
478500
assert(getBaseTypeOfSIMDType(sig->retTypeSigClass) == TYP_FLOAT);
479501

@@ -496,6 +518,7 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic,
496518
return nullptr;
497519
}
498520
break;
521+
}
499522

500523
case NI_SSE_Add:
501524
case NI_SSE_And:
@@ -530,6 +553,24 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic,
530553
retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, intrinsic, TYP_FLOAT, 16);
531554
break;
532555

556+
case NI_SSE_StaticCast:
557+
{
558+
assert(sig->numArgs == 1);
559+
var_types tgtType = getBaseTypeOfSIMDType(sig->retTypeSigClass);
560+
var_types srcType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
561+
562+
if (isNumericType(tgtType) && isNumericType(srcType))
563+
{
564+
op1 = impSIMDPopStack(TYP_SIMD16);
565+
retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, intrinsic, tgtType, 16);
566+
}
567+
else
568+
{
569+
return impUnsupportedHWIntrinsic(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, method, sig, mustExpand);
570+
}
571+
break;
572+
}
573+
533574
case NI_SSE_SetAllVector128:
534575
assert(sig->numArgs == 1);
535576
assert(getBaseTypeOfSIMDType(sig->retTypeSigClass) == TYP_FLOAT);

src/jit/lsraxarch.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,14 @@ void LinearScan::TreeNodeInfoInitHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree,
25622562
break;
25632563
}
25642564

2565+
case NI_SSE_StaticCast:
2566+
{
2567+
assert(info->srcCount == 1);
2568+
assert(info->dstCount == 1);
2569+
useList.Last()->info.isTgtPref = true;
2570+
break;
2571+
}
2572+
25652573
#ifdef _TARGET_X86_
25662574
case NI_SSE42_Crc32:
25672575
{

0 commit comments

Comments
 (0)