Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
25 changes: 25 additions & 0 deletions src/jit/hwintrinsiccodegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,31 @@ void CodeGen::genAVXIntrinsic(GenTreeHWIntrinsic* node)
}
break;
}

case NI_AVX_TestC:
{
emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
emit->emitIns_R(INS_setb, EA_1BYTE, targetReg);
break;
}

case NI_AVX_TestNotZAndNotC:
{
emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
emit->emitIns_R(INS_seta, EA_1BYTE, targetReg);
break;
}

case NI_AVX_TestZ:
{
emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
emit->emitIns_R(INS_sete, EA_1BYTE, targetReg);
break;
}

default:
unreached();
break;
Expand Down
16 changes: 14 additions & 2 deletions src/jit/hwintrinsiclistxarch.h

Large diffs are not rendered by default.

48 changes: 28 additions & 20 deletions src/jit/hwintrinsicxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,18 @@ int Compiler::ivalOfHWIntrinsic(NamedIntrinsic intrinsic)
unsigned Compiler::simdSizeOfHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_SIG_INFO* sig)
{
assert(intrinsic > NI_HW_INTRINSIC_START && intrinsic < NI_HW_INTRINSIC_END);
if ((Compiler::flagsOfHWIntrinsic(intrinsic) & HW_Flag_UnfixedSIMDSize) == 0)

HWIntrinsicFlag flags = flagsOfHWIntrinsic(intrinsic);

if ((flags & HW_Flag_UnfixedSIMDSize) == 0)
{
return hwIntrinsicInfoArray[intrinsic - NI_HW_INTRINSIC_START - 1].simdSize;
}

int simdSize = getSIMDTypeSizeInBytes(sig->retTypeSigClass);
CORINFO_CLASS_HANDLE typeHnd =
((flags & HW_Flag_BaseTypeFromArg) == 0) ? sig->retTypeSigClass : info.compCompHnd->getArgClass(sig, sig->args);

int simdSize = getSIMDTypeSizeInBytes(typeHnd);
assert(simdSize > 0);
return (unsigned)simdSize;
}
Expand Down Expand Up @@ -592,7 +598,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
var_types retType = JITtype2varType(sig->retType);
var_types baseType = TYP_UNKNOWN;

if (retType == TYP_STRUCT && featureSIMD)
if ((retType == TYP_STRUCT) && featureSIMD)
{
unsigned int sizeBytes;
baseType = getBaseTypeAndSizeOfSIMDType(sig->retTypeSigClass, &sizeBytes);
Expand Down Expand Up @@ -648,6 +654,24 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
}
}

bool isTableDriven = impIsTableDrivenHWIntrinsic(category, flags);

if (isTableDriven && (!varTypeIsSIMD(retType) || ((flags & HW_Flag_BaseTypeFromArg) != 0)))
{
if (retType != TYP_VOID)
{
baseType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
}
else
{
assert(category == HW_Category_MemoryStore);
baseType =
getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, info.compCompHnd->getArgNext(sig->args)));
}

assert(baseType != TYP_UNKNOWN);
}

if ((flags & (HW_Flag_OneTypeGeneric | HW_Flag_TwoTypeGeneric)) != 0)
{
if (!varTypeIsArithmetic(baseType))
Expand Down Expand Up @@ -675,24 +699,8 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
}

// table-driven importer of simple intrinsics
if (impIsTableDrivenHWIntrinsic(category, flags))
if (isTableDriven)
{
if (!varTypeIsSIMD(retType) || ((flags & HW_Flag_BaseTypeFromArg) != 0))
{
if (retType != TYP_VOID)
{
baseType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
}
else
{
assert(category == HW_Category_MemoryStore);
baseType =
getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, info.compCompHnd->getArgNext(sig->args)));
}

assert(baseType != TYP_UNKNOWN);
}

unsigned simdSize = simdSizeOfHWIntrinsic(intrinsic, sig);
CORINFO_ARG_LIST_HANDLE argList = sig->args;
CORINFO_CLASS_HANDLE argClass;
Expand Down
3 changes: 2 additions & 1 deletion src/jit/instrsxarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ INST3( vpermq, "permq" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SS
INST3( vblendvps, "blendvps" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4A)) // Variable Blend Packed Singles
INST3( vblendvpd, "blendvpd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4B)) // Variable Blend Packed Doubles
INST3( vpblendvb, "pblendvb" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4C)) // Variable Blend Packed Bytes

INST3( vtestps, "testps" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0x0E)) // Packed Bit Test
INST3( vtestpd, "testpd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0x0F)) // Packed Bit Test
INST3( vpsrlvd, "psrlvd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0x45)) // Variable Bit Shift Right Logical
INST3( vpsrlvq, "psrlvq" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0x45)) // Variable Bit Shift Right Logical
INST3( vpsravd, "psravd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0x46)) // Variable Bit Shift Right Arithmetic
Expand Down
52 changes: 46 additions & 6 deletions tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,64 @@
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
<Compile Include="BlendVariable.Single.cs" />
<Compile Include="Divide.Double.cs"/>
<Compile Include="Divide.Single.cs"/>
<Compile Include="Ceiling.Double.cs" />
<Compile Include="Ceiling.Single.cs" />
<Compile Include="Divide.Double.cs" />
<Compile Include="Divide.Single.cs" />
<Compile Include="DuplicateEvenIndexed.Double.cs" />
<Compile Include="DuplicateEvenIndexed.Single.cs" />
<Compile Include="DuplicateOddIndexed.Single.cs" />
<Compile Include="Floor.Double.cs" />
<Compile Include="Floor.Single.cs" />
<Compile Include="Max.Double.cs" />
<Compile Include="Max.Single.cs" />
<Compile Include="Min.Double.cs" />
<Compile Include="Min.Single.cs" />
<Compile Include="Multiply.Double.cs" />
<Compile Include="Multiply.Single.cs" />
<Compile Include="Or.Double.cs"/>
<Compile Include="Or.Single.cs"/>
<Compile Include="Or.Double.cs" />
<Compile Include="Or.Single.cs" />
<Compile Include="RoundCurrentDirection.Double.cs" />
<Compile Include="RoundCurrentDirection.Single.cs" />
<Compile Include="RoundToNearestInteger.Double.cs" />
<Compile Include="RoundToNearestInteger.Single.cs" />
<Compile Include="RoundToNegativeInfinity.Double.cs" />
<Compile Include="RoundToNegativeInfinity.Single.cs" />
<Compile Include="RoundToPositiveInfinity.Double.cs" />
<Compile Include="RoundToPositiveInfinity.Single.cs" />
<Compile Include="RoundToZero.Double.cs" />
<Compile Include="RoundToZero.Single.cs" />
<Compile Include="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
<Compile Include="TestC.Byte.cs" />
<Compile Include="TestC.Int16.cs" />
<Compile Include="TestC.Int32.cs" />
<Compile Include="TestC.Int64.cs" />
<Compile Include="TestC.SByte.cs" />
<Compile Include="TestC.UInt16.cs" />
<Compile Include="TestC.UInt32.cs" />
<Compile Include="TestC.UInt64.cs" />
<Compile Include="TestNotZAndNotC.Byte.cs" />
<Compile Include="TestNotZAndNotC.Int16.cs" />
<Compile Include="TestNotZAndNotC.Int32.cs" />
<Compile Include="TestNotZAndNotC.Int64.cs" />
<Compile Include="TestNotZAndNotC.SByte.cs" />
<Compile Include="TestNotZAndNotC.UInt16.cs" />
<Compile Include="TestNotZAndNotC.UInt32.cs" />
<Compile Include="TestNotZAndNotC.UInt64.cs" />
<Compile Include="TestZ.Byte.cs" />
<Compile Include="TestZ.Int16.cs" />
<Compile Include="TestZ.Int32.cs" />
<Compile Include="TestZ.Int64.cs" />
<Compile Include="TestZ.SByte.cs" />
<Compile Include="TestZ.UInt16.cs" />
<Compile Include="TestZ.UInt32.cs" />
<Compile Include="TestZ.UInt64.cs" />
<Compile Include="Xor.Double.cs" />
<Compile Include="Xor.Single.cs" />
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" />
<Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
<Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />
Expand Down
56 changes: 48 additions & 8 deletions tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,67 @@
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
<Compile Include="BlendVariable.Single.cs" />
<Compile Include="Divide.Double.cs"/>
<Compile Include="Divide.Single.cs"/>
<Compile Include="Ceiling.Double.cs" />
<Compile Include="Ceiling.Single.cs" />
<Compile Include="Divide.Double.cs" />
<Compile Include="Divide.Single.cs" />
<Compile Include="DuplicateEvenIndexed.Double.cs" />
<Compile Include="DuplicateEvenIndexed.Single.cs" />
<Compile Include="DuplicateOddIndexed.Single.cs" />
<Compile Include="Floor.Double.cs" />
<Compile Include="Floor.Single.cs" />
<Compile Include="Max.Double.cs" />
<Compile Include="Max.Single.cs" />
<Compile Include="Min.Double.cs" />
<Compile Include="Min.Single.cs" />
<Compile Include="Multiply.Double.cs" />
<Compile Include="Multiply.Single.cs" />
<Compile Include="Or.Double.cs"/>
<Compile Include="Or.Single.cs"/>
<Compile Include="Or.Double.cs" />
<Compile Include="Or.Single.cs" />
<Compile Include="RoundCurrentDirection.Double.cs" />
<Compile Include="RoundCurrentDirection.Single.cs" />
<Compile Include="RoundToNearestInteger.Double.cs" />
<Compile Include="RoundToNearestInteger.Single.cs" />
<Compile Include="RoundToNegativeInfinity.Double.cs" />
<Compile Include="RoundToNegativeInfinity.Single.cs" />
<Compile Include="RoundToPositiveInfinity.Double.cs" />
<Compile Include="RoundToPositiveInfinity.Single.cs" />
<Compile Include="RoundToZero.Double.cs" />
<Compile Include="RoundToZero.Single.cs" />
<Compile Include="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
<Compile Include="TestC.Byte.cs" />
<Compile Include="TestC.Int16.cs" />
<Compile Include="TestC.Int32.cs" />
<Compile Include="TestC.Int64.cs" />
<Compile Include="TestC.SByte.cs" />
<Compile Include="TestC.UInt16.cs" />
<Compile Include="TestC.UInt32.cs" />
<Compile Include="TestC.UInt64.cs" />
<Compile Include="TestNotZAndNotC.Byte.cs" />
<Compile Include="TestNotZAndNotC.Int16.cs" />
<Compile Include="TestNotZAndNotC.Int32.cs" />
<Compile Include="TestNotZAndNotC.Int64.cs" />
<Compile Include="TestNotZAndNotC.SByte.cs" />
<Compile Include="TestNotZAndNotC.UInt16.cs" />
<Compile Include="TestNotZAndNotC.UInt32.cs" />
<Compile Include="TestNotZAndNotC.UInt64.cs" />
<Compile Include="TestZ.Byte.cs" />
<Compile Include="TestZ.Int16.cs" />
<Compile Include="TestZ.Int32.cs" />
<Compile Include="TestZ.Int64.cs" />
<Compile Include="TestZ.SByte.cs" />
<Compile Include="TestZ.UInt16.cs" />
<Compile Include="TestZ.UInt32.cs" />
<Compile Include="TestZ.UInt64.cs" />
<Compile Include="Xor.Double.cs" />
<Compile Include="Xor.Single.cs" />
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" />
<Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
<Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
<Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />
<Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" />
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
Expand Down
Loading