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

Commit e84b55e

Browse files
committed
Adding support for the SSE ConvertTo Int32, Int32WithTruncation, Int64WithTruncation, Single, and Vector128Single scalar intrinsics
1 parent db75c98 commit e84b55e

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

src/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,34 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node)
344344
emit->emitIns_SIMD_R_R_R_I(INS_cmpss, targetReg, op1Reg, op2Reg, 3, TYP_SIMD16);
345345
break;
346346

347+
case NI_SSE_ConvertToInt32:
348+
case NI_SSE_ConvertToInt64:
349+
assert(baseType == TYP_FLOAT);
350+
assert(op2 == nullptr);
351+
emit->emitIns_SIMD_R_R(INS_cvtss2si, targetReg, op1Reg, TYP_SIMD16);
352+
break;
353+
354+
case NI_SSE_ConvertToInt32WithTruncation:
355+
case NI_SSE_ConvertToInt64WithTruncation:
356+
assert(baseType == TYP_FLOAT);
357+
assert(op2 == nullptr);
358+
emit->emitIns_SIMD_R_R(INS_cvttss2si, targetReg, op1Reg, TYP_SIMD16);
359+
break;
360+
361+
case NI_SSE_ConvertToSingle:
362+
assert(op2 == nullptr);
363+
if (op1Reg != targetReg)
364+
{
365+
emit->emitIns_SIMD_R_R(INS_movss, targetReg, op1Reg, TYP_SIMD16);
366+
}
367+
break;
368+
369+
case NI_SSE_ConvertToVector128SingleScalar:
370+
assert(baseType == TYP_FLOAT);
371+
op2Reg = op2->gtRegNum;
372+
emit->emitIns_SIMD_R_R_R(INS_cvtsi2ss, targetReg, op1Reg, op2Reg, TYP_SIMD16);
373+
break;
374+
347375
case NI_SSE_Divide:
348376
assert(baseType == TYP_FLOAT);
349377
op2Reg = op2->gtRegNum;

src/jit/hwintrinsicxarch.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,30 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic,
572572
retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, intrinsic, TYP_FLOAT, 16);
573573
break;
574574

575+
case NI_SSE_ConvertToVector128SingleScalar:
576+
{
577+
assert(sig->numArgs == 2);
578+
assert(getBaseTypeOfSIMDType(sig->retTypeSigClass) == TYP_FLOAT);
579+
580+
#ifdef _TARGET_X86_
581+
CORINFO_CLASS_HANDLE argClass;
582+
583+
CORINFO_ARG_LIST_HANDLE argLst = info.compCompHnd->getArgNext(sig->args);
584+
CorInfoType corType =
585+
strip(info.compCompHnd->getArgType(sig, argLst, &argClass)); // type of the second argument
586+
587+
if (varTypeIsLong(JITtype2varType(corType)))
588+
{
589+
return impUnsupportedHWIntrinsic(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, method, sig, mustExpand);
590+
}
591+
#endif // _TARGET_X86_
592+
593+
op2 = impPopStack().val;
594+
op1 = impSIMDPopStack(TYP_SIMD16);
595+
retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, intrinsic, TYP_FLOAT, 16);
596+
break;
597+
}
598+
575599
case NI_SSE_StaticCast:
576600
{
577601
assert(sig->numArgs == 1);
@@ -609,6 +633,29 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic,
609633
retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, intrinsic, TYP_FLOAT, 16);
610634
break;
611635

636+
case NI_SSE_ConvertToInt32:
637+
case NI_SSE_ConvertToInt32WithTruncation:
638+
case NI_SSE_ConvertToInt64:
639+
case NI_SSE_ConvertToInt64WithTruncation:
640+
case NI_SSE_ConvertToSingle:
641+
{
642+
assert(sig->numArgs == 1);
643+
assert(getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args)) == TYP_FLOAT);
644+
var_types callType = JITtype2varType(sig->retType);
645+
646+
#ifdef _TARGET_X86_
647+
if (varTypeIsLong(callType))
648+
{
649+
assert(intrinsic == NI_SSE_ConvertToInt64 || intrinsic == NI_SSE_ConvertToInt64WithTruncation);
650+
return impUnsupportedHWIntrinsic(CORINFO_HELP_THROW_PLATFORM_NOT_SUPPORTED, method, sig, mustExpand);
651+
}
652+
#endif // _TARGET_X86_
653+
654+
op1 = impSIMDPopStack(TYP_SIMD16);
655+
retNode = gtNewSimdHWIntrinsicNode(callType, op1, intrinsic, TYP_FLOAT, 16);
656+
break;
657+
}
658+
612659
case NI_SSE_SetZeroVector128:
613660
assert(sig->numArgs == 0);
614661
assert(getBaseTypeOfSIMDType(sig->retTypeSigClass) == TYP_FLOAT);

src/jit/lsraxarch.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,13 +2562,12 @@ void LinearScan::TreeNodeInfoInitHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree,
25622562
break;
25632563
}
25642564

2565+
case NI_SSE_ConvertToSingle:
25652566
case NI_SSE_StaticCast:
2566-
{
25672567
assert(info->srcCount == 1);
25682568
assert(info->dstCount == 1);
25692569
useList.Last()->info.isTgtPref = true;
25702570
break;
2571-
}
25722571

25732572
#ifdef _TARGET_X86_
25742573
case NI_SSE42_Crc32:

0 commit comments

Comments
 (0)