diff --git a/src/coreclr/inc/corinfoinstructionset.h b/src/coreclr/inc/corinfoinstructionset.h index 37e5e849d4afed..ca667af61aae2a 100644 --- a/src/coreclr/inc/corinfoinstructionset.h +++ b/src/coreclr/inc/corinfoinstructionset.h @@ -1044,13 +1044,13 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst case READYTORUN_INSTRUCTION_Avx512Ifma: return InstructionSet_AVX512v2; case READYTORUN_INSTRUCTION_Avx512Vbmi: return InstructionSet_AVX512v2; case READYTORUN_INSTRUCTION_Avx512Vbmi_VL: return InstructionSet_AVX512v2; - case READYTORUN_INSTRUCTION_Avx512Bitalg: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Bitalg_VL: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512BitAlg: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512BitAlg_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vbmi2: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vbmi2_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vnni: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Vpopcntdq: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Vpopcntdq_VL: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512VPopcntDQ: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512VPopcntDQ_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Bf16: return InstructionSet_AVX10v1; case READYTORUN_INSTRUCTION_Avx512Bf16_VL: return InstructionSet_AVX10v1; case READYTORUN_INSTRUCTION_Avx512Fp16: return InstructionSet_AVX10v1; @@ -1114,13 +1114,13 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst case READYTORUN_INSTRUCTION_Avx512Ifma: return InstructionSet_AVX512v2; case READYTORUN_INSTRUCTION_Avx512Vbmi: return InstructionSet_AVX512v2; case READYTORUN_INSTRUCTION_Avx512Vbmi_VL: return InstructionSet_AVX512v2; - case READYTORUN_INSTRUCTION_Avx512Bitalg: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Bitalg_VL: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512BitAlg: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512BitAlg_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vbmi2: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vbmi2_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Vnni: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Vpopcntdq: return InstructionSet_AVX512v3; - case READYTORUN_INSTRUCTION_Avx512Vpopcntdq_VL: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512VPopcntDQ: return InstructionSet_AVX512v3; + case READYTORUN_INSTRUCTION_Avx512VPopcntDQ_VL: return InstructionSet_AVX512v3; case READYTORUN_INSTRUCTION_Avx512Bf16: return InstructionSet_AVX10v1; case READYTORUN_INSTRUCTION_Avx512Bf16_VL: return InstructionSet_AVX10v1; case READYTORUN_INSTRUCTION_Avx512Fp16: return InstructionSet_AVX10v1; diff --git a/src/coreclr/inc/jiteeversionguid.h b/src/coreclr/inc/jiteeversionguid.h index 77a8a4e14f64be..fce652463c2fd3 100644 --- a/src/coreclr/inc/jiteeversionguid.h +++ b/src/coreclr/inc/jiteeversionguid.h @@ -37,11 +37,11 @@ #include -constexpr GUID JITEEVersionIdentifier = { /* c77c1a0f-c8c6-4a68-90db-4d8c1253c5ea */ - 0xc77c1a0f, - 0xc8c6, - 0x4a68, - {0x90, 0xdb, 0x4d, 0x8c, 0x12, 0x53, 0xc5, 0xea} +constexpr GUID JITEEVersionIdentifier = { /* e3eb72d0-533c-41bc-ae4d-3351f4ac81a9 */ + 0xe3eb72d0, + 0x533c, + 0x41bc, + {0xae, 0x4d, 0x33, 0x51, 0xf4, 0xac, 0x81, 0xa9} }; #endif // JIT_EE_VERSIONING_GUID_H diff --git a/src/coreclr/inc/readytoruninstructionset.h b/src/coreclr/inc/readytoruninstructionset.h index b32bf8e0a9a602..0605605bfde835 100644 --- a/src/coreclr/inc/readytoruninstructionset.h +++ b/src/coreclr/inc/readytoruninstructionset.h @@ -77,8 +77,8 @@ enum ReadyToRunInstructionSet READYTORUN_INSTRUCTION_F16C=67, READYTORUN_INSTRUCTION_Sha=68, READYTORUN_INSTRUCTION_WaitPkg=69, - READYTORUN_INSTRUCTION_Avx512Bitalg=70, - READYTORUN_INSTRUCTION_Avx512Bitalg_VL=71, + READYTORUN_INSTRUCTION_Avx512BitAlg=70, + READYTORUN_INSTRUCTION_Avx512BitAlg_VL=71, READYTORUN_INSTRUCTION_Avx512Bf16=72, READYTORUN_INSTRUCTION_Avx512Bf16_VL=73, READYTORUN_INSTRUCTION_Avx512Fp16=74, @@ -89,8 +89,8 @@ enum ReadyToRunInstructionSet READYTORUN_INSTRUCTION_Avx512Vnni=79, READYTORUN_INSTRUCTION_Avx512Vp2intersect=80, READYTORUN_INSTRUCTION_Avx512Vp2intersect_VL=81, - READYTORUN_INSTRUCTION_Avx512Vpopcntdq=82, - READYTORUN_INSTRUCTION_Avx512Vpopcntdq_VL=83, + READYTORUN_INSTRUCTION_Avx512VPopcntDQ=82, + READYTORUN_INSTRUCTION_Avx512VPopcntDQ_VL=83, READYTORUN_INSTRUCTION_Zbs=84, READYTORUN_INSTRUCTION_Avx512Bmm=85, READYTORUN_INSTRUCTION_Sha3=86, diff --git a/src/coreclr/jit/emitxarch.h b/src/coreclr/jit/emitxarch.h index 6986b7d41d8e77..f30c2fb913cfc8 100644 --- a/src/coreclr/jit/emitxarch.h +++ b/src/coreclr/jit/emitxarch.h @@ -282,6 +282,7 @@ bool HasKMaskRegisterDest(instruction ins) const case INS_vgatherqps: case INS_vgatherdpd: case INS_vgatherqpd: + case INS_vpshufbitqmb: // KMOV can be promoted to EVEX with APX. case INS_kmovb_msk: case INS_kmovw_msk: diff --git a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp index 4837eaf2f9192a..6200b7d8f458af 100644 --- a/src/coreclr/jit/hwintrinsiccodegenxarch.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenxarch.cpp @@ -938,6 +938,15 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) break; } + case NI_AVX512v3_MaskShuffleBits: + { + assert(emitter::isMaskReg(op3Reg)); + + instOptions = AddEmbMaskingMode(instOptions, op3Reg, true); + inst_RV_RV_TT(ins, simdSize, targetReg, op1Reg, op2, false, instOptions); + break; + } + default: { unreached(); diff --git a/src/coreclr/jit/hwintrinsiclistxarch.h b/src/coreclr/jit/hwintrinsiclistxarch.h index dcf31b354b8945..e17c98aed0e8a5 100644 --- a/src/coreclr/jit/hwintrinsiclistxarch.h +++ b/src/coreclr/jit/hwintrinsiclistxarch.h @@ -652,9 +652,12 @@ HARDWARE_INTRINSIC(AVX512v3, Compress, HARDWARE_INTRINSIC(AVX512v3, CompressStore, -1, 3, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, -1, -1, HW_Category_MemoryStore, HW_Flag_InvalidNodeId|HW_Flag_BaseTypeFromSecondArg) HARDWARE_INTRINSIC(AVX512v3, Expand, -1, 3, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, -1, -1, HW_Category_SimpleSIMD, HW_Flag_InvalidNodeId) HARDWARE_INTRINSIC(AVX512v3, ExpandLoad, -1, 3, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, -1, -1, HW_Category_MemoryLoad, HW_Flag_InvalidNodeId) -HARDWARE_INTRINSIC(AVX512v3, MultiplyWideningAndAdd, 64, 3, INS_invalid, INS_vpdpbusd, INS_vpdpwssd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 5, -1, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromSecondArg|HW_Flag_RmwIntrinsic) -HARDWARE_INTRINSIC(AVX512v3, MultiplyWideningAndAddSaturate, 64, 3, INS_invalid, INS_vpdpbusds, INS_vpdpwssds, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 5, -1, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromSecondArg|HW_Flag_RmwIntrinsic) -#define LAST_NI_AVX512v3 NI_AVX512v3_MultiplyWideningAndAddSaturate +HARDWARE_INTRINSIC(AVX512v3, MaskShuffleBits, -1, 3, INS_vpshufbitqmb, INS_vpshufbitqmb, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 1, -1, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_ReturnsPerElementMask) +HARDWARE_INTRINSIC(AVX512v3, MultiplyWideningAndAdd, 64, 3, INS_invalid, INS_vpdpbusd, INS_vpdpwssd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 5, -1, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromSecondArg|HW_Flag_RmwIntrinsic) +HARDWARE_INTRINSIC(AVX512v3, MultiplyWideningAndAddSaturate, 64, 3, INS_invalid, INS_vpdpbusds, INS_vpdpwssds, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 5, -1, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromSecondArg|HW_Flag_RmwIntrinsic) +HARDWARE_INTRINSIC(AVX512v3, PopCount, -1, 1, INS_vpopcntb, INS_vpopcntb, INS_vpopcntw, INS_vpopcntw, INS_vpopcntd, INS_vpopcntd, INS_vpopcntq, INS_vpopcntq, INS_invalid, INS_invalid, 3, -1, HW_Category_SimpleSIMD, HW_Flag_NoFlag) +HARDWARE_INTRINSIC(AVX512v3, ShuffleBits, -1, 2, INS_vpshufbitqmb, INS_vpshufbitqmb, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, 1, -1, HW_Category_SimpleSIMD, HW_Flag_SpecialImport|HW_Flag_ReturnsPerElementMask) +#define LAST_NI_AVX512v3 NI_AVX512v3_ShuffleBits // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // ISA Function name SIMD size NumArg Instructions IntCost FltCost Category Flags diff --git a/src/coreclr/jit/hwintrinsicxarch.cpp b/src/coreclr/jit/hwintrinsicxarch.cpp index e6cfa2e2813add..1c7db4311e60c6 100644 --- a/src/coreclr/jit/hwintrinsicxarch.cpp +++ b/src/coreclr/jit/hwintrinsicxarch.cpp @@ -216,7 +216,7 @@ CORINFO_InstructionSet Compiler::lookupInstructionSet(const char* className) { if (className[6] == 'B') { - if (strcmp(className + 7, "italg") == 0) + if (strcmp(className + 7, "itAlg") == 0) { return InstructionSet_AVX512v3; } @@ -267,7 +267,10 @@ CORINFO_InstructionSet Compiler::lookupInstructionSet(const char* className) { return InstructionSet_AVX512VP2INTERSECT; } - else if (strcmp(className + 8, "opcntdq") == 0) + } + else if (className[7] == 'P') + { + if (strcmp(className + 8, "opcntDQ") == 0) { return InstructionSet_AVX512v3; } @@ -2610,6 +2613,32 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_AVX512v3_ShuffleBits: + { + assert(sig->numArgs == 2); + + op2 = impSIMDPopStack(); + op1 = impSIMDPopStack(); + + retType = TYP_MASK; + retNode = gtNewSimdHWIntrinsicNode(retType, op1, op2, intrinsic, simdBaseType, simdSize); + break; + } + + case NI_AVX512v3_MaskShuffleBits: + { + assert(sig->numArgs == 3); + + GenTree* control = impSIMDPopStack(); + GenTree* value = impSIMDPopStack(); + GenTree* mask = impSIMDPopStack(); + + retType = TYP_MASK; + mask = gtNewSimdCvtVectorToMaskNode(TYP_MASK, mask, simdBaseType, simdSize); + retNode = gtNewSimdHWIntrinsicNode(retType, value, control, mask, intrinsic, simdBaseType, simdSize); + break; + } + case NI_AVX512_MaskLoad: case NI_AVX512_MaskLoadAligned: { diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 475d49a67c32d4..4835867381e862 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -10768,6 +10768,12 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) break; } + case NI_AVX512v3_MaskShuffleBits: + { + TryMakeSrcContainedOrRegOptional(node, op2); + break; + } + default: { assert((intrinsicId == NI_X86Base_DivRem) || (intrinsicId == NI_X86Base_X64_DivRem) || diff --git a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.cs b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.cs index fbba31a40a1ca5..805b3b89c89161 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSet.cs @@ -80,8 +80,8 @@ public enum ReadyToRunInstructionSet F16C = 67, Sha = 68, WaitPkg = 69, - Avx512Bitalg = 70, - Avx512Bitalg_VL = 71, + Avx512BitAlg = 70, + Avx512BitAlg_VL = 71, Avx512Bf16 = 72, Avx512Bf16_VL = 73, Avx512Fp16 = 74, @@ -92,8 +92,8 @@ public enum ReadyToRunInstructionSet Avx512Vnni = 79, Avx512Vp2intersect = 80, Avx512Vp2intersect_VL = 81, - Avx512Vpopcntdq = 82, - Avx512Vpopcntdq_VL = 83, + Avx512VPopcntDQ = 82, + Avx512VPopcntDQ_VL = 83, Zbs = 84, Avx512Bmm = 85, Sha3 = 86, diff --git a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.cs b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.cs index b8d0d07fdb6230..a74f7dc22016c1 100644 --- a/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.cs +++ b/src/coreclr/tools/Common/Internal/Runtime/ReadyToRunInstructionSetHelper.cs @@ -111,8 +111,8 @@ public static class ReadyToRunInstructionSetHelper case InstructionSet.X64_AVX512_X64: return ReadyToRunInstructionSet.Evex; case InstructionSet.X64_AVX512v2: return ReadyToRunInstructionSet.Avx512Ifma; case InstructionSet.X64_AVX512v2_X64: return ReadyToRunInstructionSet.Avx512Ifma; - case InstructionSet.X64_AVX512v3: return ReadyToRunInstructionSet.Avx512Bitalg; - case InstructionSet.X64_AVX512v3_X64: return ReadyToRunInstructionSet.Avx512Bitalg; + case InstructionSet.X64_AVX512v3: return ReadyToRunInstructionSet.Avx512BitAlg; + case InstructionSet.X64_AVX512v3_X64: return ReadyToRunInstructionSet.Avx512BitAlg; case InstructionSet.X64_AVX10v1: return ReadyToRunInstructionSet.Avx512Bf16; case InstructionSet.X64_AVX10v1_X64: return ReadyToRunInstructionSet.Avx512Bf16; case InstructionSet.X64_AVX10v2: return ReadyToRunInstructionSet.Avx10v2; @@ -166,7 +166,7 @@ public static class ReadyToRunInstructionSetHelper case InstructionSet.X86_AVX512_X64: return null; case InstructionSet.X86_AVX512v2: return ReadyToRunInstructionSet.Avx512Ifma; case InstructionSet.X86_AVX512v2_X64: return null; - case InstructionSet.X86_AVX512v3: return ReadyToRunInstructionSet.Avx512Bitalg; + case InstructionSet.X86_AVX512v3: return ReadyToRunInstructionSet.Avx512BitAlg; case InstructionSet.X86_AVX512v3_X64: return null; case InstructionSet.X86_AVX10v1: return ReadyToRunInstructionSet.Avx512Bf16; case InstructionSet.X86_AVX10v1_X64: return null; diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs index ed4b617cb418e3..6dbbfe09baece8 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs @@ -1248,13 +1248,13 @@ public static IEnumerable ArchitectureToValidInstructionSets yield return new InstructionSetInfo("avx512v2", "", InstructionSet.X64_AVX512v2, true); yield return new InstructionSetInfo("avx512v2", "Avx512Vbmi", InstructionSet.X64_AVX512v2, true); yield return new InstructionSetInfo("avx512v2", "Avx512Vbmi_VL", InstructionSet.X64_AVX512v2, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X64_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X64_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512BitAlg", InstructionSet.X64_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512BitAlg_VL", InstructionSet.X64_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "Avx512Vbmi2", InstructionSet.X64_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "Avx512Vbmi2_VL", InstructionSet.X64_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "AvxVnni_V512", InstructionSet.X64_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X64_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X64_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512VPopcntDQ", InstructionSet.X64_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512VPopcntDQ_VL", InstructionSet.X64_AVX512v3, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X64_AVX10v1, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X64_AVX10v1, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X64_AVX10v1, true); @@ -1322,13 +1322,13 @@ public static IEnumerable ArchitectureToValidInstructionSets yield return new InstructionSetInfo("avx512v2", "", InstructionSet.X86_AVX512v2, true); yield return new InstructionSetInfo("avx512v2", "Avx512Vbmi", InstructionSet.X86_AVX512v2, true); yield return new InstructionSetInfo("avx512v2", "Avx512Vbmi_VL", InstructionSet.X86_AVX512v2, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X86_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X86_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512BitAlg", InstructionSet.X86_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512BitAlg_VL", InstructionSet.X86_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "Avx512Vbmi2", InstructionSet.X86_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "Avx512Vbmi2_VL", InstructionSet.X86_AVX512v3, true); yield return new InstructionSetInfo("avx512v3", "AvxVnni_V512", InstructionSet.X86_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X86_AVX512v3, true); - yield return new InstructionSetInfo("avx512v3", "", InstructionSet.X86_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512VPopcntDQ", InstructionSet.X86_AVX512v3, true); + yield return new InstructionSetInfo("avx512v3", "Avx512VPopcntDQ_VL", InstructionSet.X86_AVX512v3, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X86_AVX10v1, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X86_AVX10v1, true); yield return new InstructionSetInfo("avx10v1", "", InstructionSet.X86_AVX10v1, true); @@ -1848,6 +1848,18 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite else return InstructionSet.X64_AVX512v2; + case "Avx512BitAlg": + if (nestedTypeName == "X64") + return InstructionSet.X64_AVX512v3_X64; + else + if (nestedTypeName == "VL_X64") + return InstructionSet.X64_AVX512v3_X64; + else + if (nestedTypeName == "VL") + return InstructionSet.X64_AVX512v3; + else + return InstructionSet.X64_AVX512v3; + case "Avx512Vbmi2": if (nestedTypeName == "X64") return InstructionSet.X64_AVX512v3_X64; @@ -1860,6 +1872,18 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite else return InstructionSet.X64_AVX512v3; + case "Avx512VPopcntDQ": + if (nestedTypeName == "X64") + return InstructionSet.X64_AVX512v3_X64; + else + if (nestedTypeName == "VL_X64") + return InstructionSet.X64_AVX512v3_X64; + else + if (nestedTypeName == "VL") + return InstructionSet.X64_AVX512v3; + else + return InstructionSet.X64_AVX512v3; + case "Avx10v1": if (nestedTypeName == "X64") return InstructionSet.X64_AVX10v1_X64; @@ -2025,12 +2049,24 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite else return InstructionSet.X86_AVX512v2; + case "Avx512BitAlg": + if (nestedTypeName == "VL") + return InstructionSet.X86_AVX512v3; + else + return InstructionSet.X86_AVX512v3; + case "Avx512Vbmi2": if (nestedTypeName == "VL") return InstructionSet.X86_AVX512v3; else return InstructionSet.X86_AVX512v3; + case "Avx512VPopcntDQ": + if (nestedTypeName == "VL") + return InstructionSet.X86_AVX512v3; + else + return InstructionSet.X86_AVX512v3; + case "Avx10v1": if (nestedTypeName == "V512") return InstructionSet.X86_AVX10v1; @@ -2840,6 +2876,41 @@ public static IEnumerable LookupPlatformIntrinsicTypes(TypeSystemC case (InstructionSet.X64_AVX512v3, TargetArchitecture.X64): case (InstructionSet.X64_AVX512v3_X64, TargetArchitecture.X64): + { + var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512BitAlg"u8, false); + if (type != null) + { + yield return type; + if (instructionSet == InstructionSet.X64_AVX512v3_X64) + { + var nestedType = type.GetNestedType("X64"u8); + if (nestedType != null) + { + yield return nestedType; + } + } + } + } + { + var parentType = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512BitAlg"u8, false); + if (parentType != null) + { + yield return parentType; + var nestedType = parentType.GetNestedType("VL"u8); + if (nestedType != null) + { + yield return nestedType; + if (instructionSet == InstructionSet.X64_AVX512v3_X64) + { + var nestedType64 = parentType.GetNestedType("VL_X64"u8); + if (nestedType64 != null) + { + yield return nestedType64; + } + } + } + } + } { var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512Vbmi2"u8, false); if (type != null) @@ -2895,6 +2966,41 @@ public static IEnumerable LookupPlatformIntrinsicTypes(TypeSystemC } } } + { + var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512VPopcntDQ"u8, false); + if (type != null) + { + yield return type; + if (instructionSet == InstructionSet.X64_AVX512v3_X64) + { + var nestedType = type.GetNestedType("X64"u8); + if (nestedType != null) + { + yield return nestedType; + } + } + } + } + { + var parentType = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512VPopcntDQ"u8, false); + if (parentType != null) + { + yield return parentType; + var nestedType = parentType.GetNestedType("VL"u8); + if (nestedType != null) + { + yield return nestedType; + if (instructionSet == InstructionSet.X64_AVX512v3_X64) + { + var nestedType64 = parentType.GetNestedType("VL_X64"u8); + if (nestedType64 != null) + { + yield return nestedType64; + } + } + } + } + } break; case (InstructionSet.X64_AVX10v1, TargetArchitecture.X64): @@ -3389,6 +3495,25 @@ public static IEnumerable LookupPlatformIntrinsicTypes(TypeSystemC break; case (InstructionSet.X86_AVX512v3, TargetArchitecture.X86): + { + var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512BitAlg"u8, false); + if (type != null) + { + yield return type; + } + } + { + var parentType = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512BitAlg"u8, false); + if (parentType != null) + { + yield return parentType; + var nestedType = parentType.GetNestedType("VL"u8); + if (nestedType != null) + { + yield return nestedType; + } + } + } { var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512Vbmi2"u8, false); if (type != null) @@ -3420,6 +3545,25 @@ public static IEnumerable LookupPlatformIntrinsicTypes(TypeSystemC } } } + { + var type = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512VPopcntDQ"u8, false); + if (type != null) + { + yield return type; + } + } + { + var parentType = context.SystemModule.GetType("System.Runtime.Intrinsics.X86"u8, "Avx512VPopcntDQ"u8, false); + if (parentType != null) + { + yield return parentType; + var nestedType = parentType.GetNestedType("VL"u8); + if (nestedType != null) + { + yield return nestedType; + } + } + } break; case (InstructionSet.X86_AVX10v1, TargetArchitecture.X86): diff --git a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt index 291232886e83de..bba98849647823 100644 --- a/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt +++ b/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt @@ -65,13 +65,13 @@ instructionset ,X86 , ,Avx512Ifma ,76 ,AVX512v instructionset ,X86 ,Avx512Vbmi , ,37 ,AVX512v2 ,avx512v2 instructionset ,X86 ,Avx512Vbmi_VL , ,38 ,AVX512v2 ,avx512v2 -instructionset ,X86 , ,Avx512Bitalg ,70 ,AVX512v3 ,avx512v3 -instructionset ,X86 , ,Avx512Bitalg_VL ,71 ,AVX512v3 ,avx512v3 +instructionset ,X86 ,Avx512BitAlg , ,70 ,AVX512v3 ,avx512v3 +instructionset ,X86 ,Avx512BitAlg_VL , ,71 ,AVX512v3 ,avx512v3 instructionset ,X86 ,Avx512Vbmi2 , ,77 ,AVX512v3 ,avx512v3 instructionset ,X86 ,Avx512Vbmi2_VL , ,78 ,AVX512v3 ,avx512v3 instructionset ,X86 ,AvxVnni_V512 ,Avx512Vnni ,79 ,AVX512v3 ,avx512v3 -instructionset ,X86 , ,Avx512Vpopcntdq ,82 ,AVX512v3 ,avx512v3 -instructionset ,X86 , ,Avx512Vpopcntdq_VL ,83 ,AVX512v3 ,avx512v3 +instructionset ,X86 ,Avx512VPopcntDQ , ,82 ,AVX512v3 ,avx512v3 +instructionset ,X86 ,Avx512VPopcntDQ_VL , ,83 ,AVX512v3 ,avx512v3 instructionset ,X86 , ,Avx512Bf16 ,72 ,AVX10v1 ,avx10v1 instructionset ,X86 , ,Avx512Bf16_VL ,73 ,AVX10v1 ,avx10v1 diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 69378d095e636f..15d4636bd922e3 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -2871,9 +2871,11 @@ + + @@ -2898,6 +2900,7 @@ + @@ -2907,6 +2910,7 @@ + diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.PlatformNotSupported.cs new file mode 100644 index 00000000000000..a8891d1d76457b --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.PlatformNotSupported.cs @@ -0,0 +1,184 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.X86 +{ + /// Provides access to the x86 AVX512BITALG hardware instructions via Intrinsics. + [CLSCompliant(false)] + public abstract class Avx512BitAlg : Avx512BW + { + internal Avx512BitAlg() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + + public new abstract class X64 : Avx512BW.X64 + { + internal X64() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + } + + /// + /// __m512i _mm512_popcnt_epi8(__m512i) + /// VPOPCNTB zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi8(__m512i) + /// VPOPCNTB zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi16(__m512i) + /// VPOPCNTW zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi16(__m512i) + /// VPOPCNTW zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask64 _mm512_bitshuffle_epi64_mask(__m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 ShuffleBits(Vector512 value, Vector512 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask64 _mm512_bitshuffle_epi64_mask(__m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 ShuffleBits(Vector512 value, Vector512 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask64,_mm512_mask_bitshuffle_epi64_mask(__mmask64, __m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 MaskShuffleBits(Vector512 mask, Vector512 value, Vector512 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask64 _mm512_mask_bitshuffle_epi64_mask(__mmask64, __m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 MaskShuffleBits(Vector512 mask, Vector512 value, Vector512 control) { throw new PlatformNotSupportedException(); } + + public new abstract class VL : Avx512BW.VL + { + internal VL() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + + /// + /// __m256i _mm256_popcnt_epi8(__m256i) + /// VPOPCNTB ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi8(__m256i) + /// VPOPCNTB ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi16(__m256i) + /// VPOPCNTW ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi16(__m256i) + /// VPOPCNTW ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask32 _mm256_bitshuffle_epi64_mask(__m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 ShuffleBits(Vector256 value, Vector256 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask32 _mm256_bitshuffle_epi64_mask(__m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 ShuffleBits(Vector256 value, Vector256 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask32,_mm256_mask_bitshuffle_epi64_mask(__mmask64, __m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 MaskShuffleBits(Vector256 mask, Vector256 value, Vector256 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask32 _mm256_mask_bitshuffle_epi64_mask(__mmask64, __m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 MaskShuffleBits(Vector256 mask, Vector256 value, Vector256 control) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm128_popcnt_epi8(__m128i) + /// VPOPCNTB xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm128_popcnt_epi8(__m128i) + /// VPOPCNTB xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm128_popcnt_epi16(__m128i) + /// VPOPCNTW xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm128_popcnt_epi16(__m128i) + /// VPOPCNTW xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask16 _mm_bitshuffle_epi64_mask(__m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 ShuffleBits(Vector128 value, Vector128 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask16 _mm_bitshuffle_epi64_mask(__m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 ShuffleBits(Vector128 value, Vector128 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask16 _mm_mask_bitshuffle_epi64_mask(__mmask64, __m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 MaskShuffleBits(Vector128 mask, Vector128 value, Vector128 control) { throw new PlatformNotSupportedException(); } + + /// + /// __mmask16 _mm_mask_bitshuffle_epi64_mask(__mmask64, __m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 MaskShuffleBits(Vector128 mask, Vector128 value, Vector128 control) { throw new PlatformNotSupportedException(); } + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.cs new file mode 100644 index 00000000000000..472a0ab3a097c8 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512BitAlg.cs @@ -0,0 +1,187 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.X86 +{ + /// Provides access to the x86 AVX512BITALG hardware instructions via Intrinsics. + [Intrinsic] + [CLSCompliant(false)] + public abstract class Avx512BitAlg : Avx512BW + { + internal Avx512BitAlg() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + + [Intrinsic] + public new abstract class X64 : Avx512BW.X64 + { + internal X64() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + } + + /// + /// __m512i _mm512_popcnt_epi8(__m512i) + /// VPOPCNTB zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi8(__m512i) + /// VPOPCNTB zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi16(__m512i) + /// VPOPCNTW zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi16(__m512i) + /// VPOPCNTW zmm1{k1}{z}, zmm2/mm512 + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __mmask64 _mm512_bitshuffle_epi64_mask(__m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 ShuffleBits(Vector512 value, Vector512 control) => ShuffleBits(value, control); + + /// + /// __mmask64 _mm512_bitshuffle_epi64_mask(__m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 ShuffleBits(Vector512 value, Vector512 control) => ShuffleBits(value, control); + + /// + /// __mmask64,_mm512_mask_bitshuffle_epi64_mask(__mmask64, __m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 MaskShuffleBits(Vector512 mask, Vector512 value, Vector512 control) => MaskShuffleBits(mask, value, control); + + /// + /// __mmask64 _mm512_mask_bitshuffle_epi64_mask(__mmask64, __m512i, __m512i) + /// VPSHUFBITQMB k1{k2}, zmm2, zmm3/m512 + /// + public static Vector512 MaskShuffleBits(Vector512 mask, Vector512 value, Vector512 control) => MaskShuffleBits(mask, value, control); + + [Intrinsic] + public new abstract class VL : Avx512BW.VL + { + internal VL() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + + /// + /// __m256i _mm256_popcnt_epi8(__m256i) + /// VPOPCNTB ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi8(__m256i) + /// VPOPCNTB ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi16(__m256i) + /// VPOPCNTW ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi16(__m256i) + /// VPOPCNTW ymm1{k1}{z}, ymm2/mm256 + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __mmask32 _mm256_bitshuffle_epi64_mask(__m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 ShuffleBits(Vector256 value, Vector256 control) => ShuffleBits(value, control); + + /// + /// __mmask32 _mm256_bitshuffle_epi64_mask(__m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 ShuffleBits(Vector256 value, Vector256 control) => ShuffleBits(value, control); + + /// + /// __mmask32,_mm256_mask_bitshuffle_epi64_mask(__mmask64, __m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 MaskShuffleBits(Vector256 mask, Vector256 value, Vector256 control) => MaskShuffleBits(mask, value, control); + + /// + /// __mmask32 _mm256_mask_bitshuffle_epi64_mask(__mmask64, __m256i, __m256i) + /// VPSHUFBITQMB k1{k2}, ymm2, ymm3/m256 + /// + public static Vector256 MaskShuffleBits(Vector256 mask, Vector256 value, Vector256 control) => MaskShuffleBits(mask, value, control); + + /// + /// __m128i _mm128_popcnt_epi8(__m128i) + /// VPOPCNTB xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm128_popcnt_epi8(__m128i) + /// VPOPCNTB xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm128_popcnt_epi16(__m128i) + /// VPOPCNTW xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm128_popcnt_epi16(__m128i) + /// VPOPCNTW xmm1{k1}{z}, xmm2/mm128 + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __mmask16 _mm_bitshuffle_epi64_mask(__m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 ShuffleBits(Vector128 value, Vector128 control) => ShuffleBits(value, control); + + /// + /// __mmask16 _mm_bitshuffle_epi64_mask(__m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 ShuffleBits(Vector128 value, Vector128 control) => ShuffleBits(value, control); + + /// + /// __mmask16 _mm_mask_bitshuffle_epi64_mask(__mmask64, __m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 MaskShuffleBits(Vector128 mask, Vector128 value, Vector128 control) => MaskShuffleBits(mask, value, control); + + /// + /// __mmask16 _mm_mask_bitshuffle_epi64_mask(__mmask64, __m128i, __m128i) + /// VPSHUFBITQMB k1{k2}, xmm2, xmm3/m128 + /// + public static Vector128 MaskShuffleBits(Vector128 mask, Vector128 value, Vector128 control) => MaskShuffleBits(mask, value, control); + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.PlatformNotSupported.cs new file mode 100644 index 00000000000000..b37ff1bd97d1aa --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.PlatformNotSupported.cs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.X86 +{ + /// Provides access to the x86 AVX512VPopcntDQ hardware instructions via intrinsics. + [CLSCompliant(false)] + public abstract class Avx512VPopcntDQ : Avx512DQ + { + internal Avx512VPopcntDQ() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + + public new abstract class X64 : Avx512DQ.X64 + { + internal X64() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + } + + /// + /// __m512i _mm512_popcnt_epi32(__m512i) + /// VPOPCNTD zmm1{k1}{z}, zmm2/mm512/m32bcst + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi32(__m512i) + /// VPOPCNTD zmm1{k1}{z}, zmm2/mm512/m32bcst + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi64(__m512i) + /// VPOPCNTQ zmm1{k1}{z}, zmm2/mm512/m64bcst + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m512i _mm512_popcnt_epi64(__m512i) + /// VPOPCNTQ zmm1{k1}{z}, zmm2/mm512/m64bcst + /// + public static Vector512 PopCount(Vector512 value) { throw new PlatformNotSupportedException(); } + + public new abstract class VL : Avx512DQ.VL + { + internal VL() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { [Intrinsic] get { return false; } } + + /// + /// __m256i _mm256_popcnt_epi32(__m256i) + /// VPOPCNTD ymm1{k1}{z}, ymm2/mm256/m32bcst + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi32(__m256i) + /// VPOPCNTD ymm1{k1}{z}, ymm2/mm256/m32bcst + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi64(__m256i) + /// VPOPCNTQ ymm1{k1}{z}, ymm2/mm256/m64bcst + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m256i _mm256_popcnt_epi64(__m256i) + /// VPOPCNTQ ymm1{k1}{z}, ymm2/mm256/m64bcst + /// + public static Vector256 PopCount(Vector256 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm_popcnt_epi32(__m128i) + /// VPOPCNTD xmm1{k1}{z}, xmm2/mm128/m32bcst + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm_popcnt_epi32(__m128i) + /// VPOPCNTD xmm1{k1}{z}, xmm2/mm128/m32bcst + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm_popcnt_epi64(__m128i) + /// VPOPCNTQ xmm1{k1}{z}, xmm2/mm128/m64bcst + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + + /// + /// __m128i _mm_popcnt_epi64(__m128i) + /// VPOPCNTQ xmm1{k1}{z}, xmm2/mm128/m64bcst + /// + public static Vector128 PopCount(Vector128 value) { throw new PlatformNotSupportedException(); } + } + } +} diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.cs new file mode 100644 index 00000000000000..d87bb0c0fb7308 --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx512VPopcntDQ.cs @@ -0,0 +1,115 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; + +namespace System.Runtime.Intrinsics.X86 +{ + /// Provides access to the x86 AVX512VPopcntDQ hardware instructions via intrinsics. + [Intrinsic] + [CLSCompliant(false)] + public abstract class Avx512VPopcntDQ : Avx512DQ + { + internal Avx512VPopcntDQ() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + + [Intrinsic] + public new abstract class X64 : Avx512DQ.X64 + { + internal X64() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + } + + /// + /// __m512i _mm512_popcnt_epi32(__m512i) + /// VPOPCNTD zmm1{k1}{z}, zmm2/mm512/m32bcst + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi32(__m512i) + /// VPOPCNTD zmm1{k1}{z}, zmm2/mm512/m32bcst + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi64(__m512i) + /// VPOPCNTQ zmm1{k1}{z}, zmm2/mm512/m64bcst + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + /// + /// __m512i _mm512_popcnt_epi64(__m512i) + /// VPOPCNTQ zmm1{k1}{z}, zmm2/mm512/m64bcst + /// + public static Vector512 PopCount(Vector512 value) => PopCount(value); + + [Intrinsic] + public new abstract class VL : Avx512DQ.VL + { + internal VL() { } + + /// Gets a value that indicates whether the APIs in this class are supported. + /// if the APIs are supported; otherwise, . + /// A value of indicates that the APIs will throw . + public static new bool IsSupported { get => IsSupported; } + + /// + /// __m256i _mm256_popcnt_epi32(__m256i) + /// VPOPCNTD ymm1{k1}{z}, ymm2/mm256/m32bcst + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi32(__m256i) + /// VPOPCNTD ymm1{k1}{z}, ymm2/mm256/m32bcst + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi64(__m256i) + /// VPOPCNTQ ymm1{k1}{z}, ymm2/mm256/m64bcst + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m256i _mm256_popcnt_epi64(__m256i) + /// VPOPCNTQ ymm1{k1}{z}, ymm2/mm256/m64bcst + /// + public static Vector256 PopCount(Vector256 value) => PopCount(value); + + /// + /// __m128i _mm_popcnt_epi32(__m128i) + /// VPOPCNTD xmm1{k1}{z}, xmm2/mm128/m32bcst + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm_popcnt_epi32(__m128i) + /// VPOPCNTD xmm1{k1}{z}, xmm2/mm128/m32bcst + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm_popcnt_epi64(__m128i) + /// VPOPCNTQ xmm1{k1}{z}, xmm2/mm128/m64bcst + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + + /// + /// __m128i _mm_popcnt_epi64(__m128i) + /// VPOPCNTQ xmm1{k1}{z}, xmm2/mm128/m64bcst + /// + public static Vector128 PopCount(Vector128 value) => PopCount(value); + } + } +} diff --git a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs index 93751320e6bf40..d80511ad534355 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -9048,6 +9048,47 @@ internal X64() { } } } + [System.CLSCompliantAttribute(false)] + public abstract partial class Avx512BitAlg : System.Runtime.Intrinsics.X86.Avx512BW + { + internal Avx512BitAlg() { } + public static new bool IsSupported { get { throw null; } } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 ShuffleBits(System.Runtime.Intrinsics.Vector512 value, System.Runtime.Intrinsics.Vector512 control) { throw null; } + public static System.Runtime.Intrinsics.Vector512 ShuffleBits(System.Runtime.Intrinsics.Vector512 value, System.Runtime.Intrinsics.Vector512 control) { throw null; } + public static System.Runtime.Intrinsics.Vector512 MaskShuffleBits(System.Runtime.Intrinsics.Vector512 mask, System.Runtime.Intrinsics.Vector512 value, System.Runtime.Intrinsics.Vector512 control) { throw null; } + public static System.Runtime.Intrinsics.Vector512 MaskShuffleBits(System.Runtime.Intrinsics.Vector512 mask, System.Runtime.Intrinsics.Vector512 value, System.Runtime.Intrinsics.Vector512 control) { throw null; } + public new abstract partial class VL : System.Runtime.Intrinsics.X86.Avx512BW.VL + { + internal VL() { } + public static new bool IsSupported { get { throw null; } } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 ShuffleBits(System.Runtime.Intrinsics.Vector256 value, System.Runtime.Intrinsics.Vector256 control) { throw null; } + public static System.Runtime.Intrinsics.Vector256 ShuffleBits(System.Runtime.Intrinsics.Vector256 value, System.Runtime.Intrinsics.Vector256 control) { throw null; } + public static System.Runtime.Intrinsics.Vector256 MaskShuffleBits(System.Runtime.Intrinsics.Vector256 mask, System.Runtime.Intrinsics.Vector256 value, System.Runtime.Intrinsics.Vector256 control) { throw null; } + public static System.Runtime.Intrinsics.Vector256 MaskShuffleBits(System.Runtime.Intrinsics.Vector256 mask, System.Runtime.Intrinsics.Vector256 value, System.Runtime.Intrinsics.Vector256 control) { throw null; } + public static System.Runtime.Intrinsics.Vector128 ShuffleBits(System.Runtime.Intrinsics.Vector128 value, System.Runtime.Intrinsics.Vector128 control) { throw null; } + public static System.Runtime.Intrinsics.Vector128 ShuffleBits(System.Runtime.Intrinsics.Vector128 value, System.Runtime.Intrinsics.Vector128 control) { throw null; } + public static System.Runtime.Intrinsics.Vector128 MaskShuffleBits(System.Runtime.Intrinsics.Vector128 mask, System.Runtime.Intrinsics.Vector128 value, System.Runtime.Intrinsics.Vector128 control) { throw null; } + public static System.Runtime.Intrinsics.Vector128 MaskShuffleBits(System.Runtime.Intrinsics.Vector128 mask, System.Runtime.Intrinsics.Vector128 value, System.Runtime.Intrinsics.Vector128 control) { throw null; } + } + public new abstract partial class X64 : System.Runtime.Intrinsics.X86.Avx512BW.X64 + { + internal X64() { } + public static new bool IsSupported { get { throw null; } } + } + } + [System.CLSCompliantAttribute(false)] public abstract partial class Avx512BW : System.Runtime.Intrinsics.X86.Avx512F { @@ -10501,6 +10542,36 @@ internal X64() { } public static ulong ConvertToUInt64WithTruncation(System.Runtime.Intrinsics.Vector128 value) { throw null; } } } + + [System.CLSCompliantAttribute(false)] + public abstract partial class Avx512VPopcntDQ : System.Runtime.Intrinsics.X86.Avx512DQ + { + internal Avx512VPopcntDQ() { } + public static new bool IsSupported { get { throw null; } } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public static System.Runtime.Intrinsics.Vector512 PopCount(System.Runtime.Intrinsics.Vector512 value) { throw null; } + public new abstract partial class VL : System.Runtime.Intrinsics.X86.Avx512DQ.VL + { + internal VL() { } + public static new bool IsSupported { get { throw null; } } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector256 PopCount(System.Runtime.Intrinsics.Vector256 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + public static System.Runtime.Intrinsics.Vector128 PopCount(System.Runtime.Intrinsics.Vector128 value) { throw null; } + } + public new abstract partial class X64 : System.Runtime.Intrinsics.X86.Avx512DQ.X64 + { + internal X64() { } + public static new bool IsSupported { get { throw null; } } + } + } + [System.CLSCompliantAttribute(false)] public abstract partial class Avx512Vbmi : System.Runtime.Intrinsics.X86.Avx512BW { diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_X86.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_X86.cs index 30c92a29703334..94eab11217d656 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_X86.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_X86.cs @@ -3069,6 +3069,48 @@ ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx512DQ.VL", ["LoadIsa"] = "Avx", ["Method"] = "Reduce", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Avx512Verify.Reduce(firstOp[0], 1)) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(Avx512Verify.Reduce(firstOp[i], 1)) != BitConverter.SingleToInt32Bits(result[i])"}), }; +(string templateFileName, Dictionary templateData)[] Avx512VPopcntDQInputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +}; + +(string templateFileName, Dictionary templateData)[] Avx512BitAlgInputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg", ["LoadIsa"] = "Avx512F", ["Method"] = "PopCount", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +}; + +(string templateFileName, Dictionary templateData)[] Avx512VPopcntDQ_VL_Vector128Inputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +}; + +(string templateFileName, Dictionary templateData)[] Avx512VPopcntDQ_VL_Vector256Inputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt32()", ["ValidateFirstResult"] = "result[0] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateFirstResult"] = "result[0] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt32)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt64()", ["ValidateFirstResult"] = "result[0] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512VPopcntDQ.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt64)System.Numerics.BitOperations.PopCount(unchecked((UInt64)firstOp[i]))", }), +}; + +(string templateFileName, Dictionary templateData)[] Avx512BitAlg_VL_Vector128Inputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Sse2", ["Method"] = "PopCount", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +}; + +(string templateFileName, Dictionary templateData)[] Avx512BitAlg_VL_Vector256Inputs = new [] { +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["ValidateFirstResult"] = "result[0] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (SByte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(Byte)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["ValidateFirstResult"] = "result[0] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Byte)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetInt16()", ["ValidateFirstResult"] = "result[0] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (Int16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)(UInt16)firstOp[i]))", }), +("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx512BitAlg.VL", ["LoadIsa"] = "Avx", ["Method"] = "PopCount", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt16()", ["ValidateFirstResult"] = "result[0] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[0]))", ["ValidateRemainingResults"] = "result[i] != (UInt16)System.Numerics.BitOperations.PopCount(unchecked((UInt32)firstOp[i]))", }), +}; + (string templateFileName, Dictionary templateData)[] Avx512VbmiInputs = new [] { ("MultiShiftTest.template", new Dictionary { ["Isa"] = "Avx512Vbmi", ["LoadIsa"] = "Avx512F", ["Method"] = "MultiShift", ["RetVectorType"] = "Vector512", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector512", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector512", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetUInt64()", ["ValidateFirstResult"] = "result[0] != MultiShift(left, right, 0)", ["ValidateRemainingResults"] = "result[i] != MultiShift(left, right, i)"}), @@ -4490,6 +4532,12 @@ bool isImmTemplate(string name) ProcessInputs("Avx512DQ_ScalarUpper", Avx512DQ_ScalarUpperInputs); ProcessInputs("Avx512DQ_VL_Vector128", Avx512DQ_VL_Vector128Inputs); ProcessInputs("Avx512DQ_VL_Vector256", Avx512DQ_VL_Vector256Inputs); +ProcessInputs("Avx512VPopcntDQ", Avx512VPopcntDQInputs); +ProcessInputs("Avx512VPopcntDQ_VL_Vector128", Avx512VPopcntDQ_VL_Vector128Inputs); +ProcessInputs("Avx512VPopcntDQ_VL_Vector256", Avx512VPopcntDQ_VL_Vector256Inputs); +ProcessInputs("Avx512BitAlg", Avx512BitAlgInputs); +ProcessInputs("Avx512BitAlg_VL_Vector128", Avx512BitAlg_VL_Vector128Inputs); +ProcessInputs("Avx512BitAlg_VL_Vector256", Avx512BitAlg_VL_Vector256Inputs); ProcessInputs("Avx512Vbmi", Avx512VbmiInputs); ProcessInputs("Avx512Vbmi_VL_Vector128", Avx512Vbmi_VL_Vector128Inputs); ProcessInputs("Avx512Vbmi_VL_Vector256", Avx512Vbmi_VL_Vector256Inputs); diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_r.csproj new file mode 100644 index 00000000000000..af6fff2af07a85 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_r.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_handwritten_r + true + + + Embedded + + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_ro.csproj new file mode 100644 index 00000000000000..3249f53cce012e --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_handwritten_ro.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_handwritten_ro + true + + + Embedded + True + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_r.csproj new file mode 100644 index 00000000000000..cd1ffbf54693c5 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_ro.csproj new file mode 100644 index 00000000000000..22e7737c1f0bb1 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Avx512BitAlg_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Program.Avx512BitAlg.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Program.Avx512BitAlg.cs new file mode 100644 index 00000000000000..a29bfdbd23a703 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/Program.Avx512BitAlg.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512BitAlg +{ + public static partial class Program + { + static Program() + { + + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/ShuffleBits.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/ShuffleBits.cs new file mode 100644 index 00000000000000..4a1f3c43978472 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg/ShuffleBits.cs @@ -0,0 +1,74 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using JIT.HardwareIntrinsics.X86; +using Xunit; + +namespace IntelHardwareIntrinsicTest._Avx512BitAlg +{ + public partial class Program + { + [Fact] + public static unsafe void ShuffleBits() + { + if (!Avx512BitAlg.IsSupported) + return; + + ulong[] value = new ulong[Vector512.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector512.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleBinaryOpTest__DataTable(value, control, new byte[64], 64); + + Vector512 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector512 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector512 actual = Avx512BitAlg.ShuffleBits(op1, op2); + + for (int i = 0; i < Vector512.Count; ++i) + { + ulong iQword = op1[i / 8]; + int idxShift = op2[i] & 63; + ulong shufBit = (iQword >> idxShift) & 1ul; + byte expected = (byte)(shufBit == 1ul ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + + [Fact] + public static unsafe void MaskShuffleBits() + { + if (!Avx512BitAlg.IsSupported) + return; + + byte[] mask = new byte[Vector512.Count]; + for (int i = 0; i < mask.Length; ++i) mask[i] = TestLibrary.Generator.GetByte(); + ulong[] value = new ulong[Vector512.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector512.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleTernaryOpTest__DataTable(mask, value, control, new byte[64], 64); + + Vector512 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector512 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector512 op3 = Unsafe.Read>(table.inArray3Ptr); + Vector512 actual = Avx512BitAlg.MaskShuffleBits(op1, op2, op3); + + for (int i = 0; i < Vector512.Count; ++i) + { + bool mask_i = (op1[i] & 0x80) == 0x80; + + ulong iQword = op2[i / 8]; + int idxShift = op3[i] & 63; + ulong shufBit = (iQword >> idxShift) & 1ul; + byte expected = (byte)((mask_i && shufBit == 1ul) ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + } +} + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_r.csproj new file mode 100644 index 00000000000000..fc2d454ab77297 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_r.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_VL_Vector128_handwritten_r + true + + + Embedded + + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_ro.csproj new file mode 100644 index 00000000000000..c7f9bd9f65feaa --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_handwritten_ro.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_VL_Vector128_handwritten_ro + true + + + Embedded + True + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_r.csproj new file mode 100644 index 00000000000000..9771c560cdc119 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_VL_Vector128_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_ro.csproj new file mode 100644 index 00000000000000..a1a06c81dae0e2 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Avx512BitAlg_VL_Vector128_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_VL_Vector128_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Program.Avx512BitAlg_VL_Vector128.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Program.Avx512BitAlg_VL_Vector128.cs new file mode 100644 index 00000000000000..9b65495d174c91 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/Program.Avx512BitAlg_VL_Vector128.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512BitAlg_VL_Vector128 +{ + public static partial class Program + { + static Program() + { + + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/ShuffleBits.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/ShuffleBits.cs new file mode 100644 index 00000000000000..453ea93a04b04e --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector128/ShuffleBits.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using JIT.HardwareIntrinsics.X86; +using Xunit; + +namespace IntelHardwareIntrinsicTest._Avx512BitAlg_VL_Vector128 +{ + public partial class Program + { + [Fact] + public static unsafe void ShuffleBitsVector128() + { + if (!Avx512BitAlg.VL.IsSupported) + return; + + ulong[] value = new ulong[Vector128.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector128.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleBinaryOpTest__DataTable(value, control, new byte[16], 16); + + Vector128 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector128 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector128 actual = Avx512BitAlg.VL.ShuffleBits(op1, op2); + + for (int i = 0; i < Vector128.Count; ++i) + { + ulong qword_i = op1[i / 8]; + int idx_shift = op2[i] & 63; + ulong shufbit = (qword_i >> idx_shift) & 1ul; + byte expected = (byte)(shufbit == 1ul ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + + [Fact] + public static unsafe void MaskShuffleBitsVector128() + { + if (!Avx512BitAlg.VL.IsSupported) + return; + + byte[] mask = new byte[Vector128.Count]; + for (int i = 0; i < mask.Length; ++i) mask[i] = TestLibrary.Generator.GetByte(); + ulong[] value = new ulong[Vector128.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector128.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleTernaryOpTest__DataTable(mask, value, control, new byte[16], 16); + + Vector128 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector128 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector128 op3 = Unsafe.Read>(table.inArray3Ptr); + Vector128 actual = Avx512BitAlg.VL.MaskShuffleBits(op1, op2, op3); + + for (int i = 0; i < Vector128.Count; ++i) + { + bool mask_i = (op1[i] & 0x80) == 0x80; + + ulong qword_i = op2[i / 8]; + int idx_shift = op3[i] & 63; + ulong shufbit = (qword_i >> idx_shift) & 1ul; + byte expected = (byte)((mask_i && shufbit == 1ul) ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_r.csproj new file mode 100644 index 00000000000000..ca87af6ffe370c --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_r.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_VL_Vector256_handwritten_r + true + + + Embedded + + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_ro.csproj new file mode 100644 index 00000000000000..3f535947eb95c9 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_handwritten_ro.csproj @@ -0,0 +1,15 @@ + + + X86_Avx512BitAlg_VL_Vector256_handwritten_ro + true + + + Embedded + True + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_r.csproj new file mode 100644 index 00000000000000..b633d27cd5eeef --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_VL_Vector256_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_ro.csproj new file mode 100644 index 00000000000000..09d0a80c45646c --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Avx512BitAlg_VL_Vector256_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512BitAlg_VL_Vector256_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Program.Avx512BitAlg_VL_Vector256.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Program.Avx512BitAlg_VL_Vector256.cs new file mode 100644 index 00000000000000..56f75a7d9e5927 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/Program.Avx512BitAlg_VL_Vector256.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512BitAlg_VL_Vector256 +{ + public static partial class Program + { + static Program() + { + + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/ShuffleBits.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/ShuffleBits.cs new file mode 100644 index 00000000000000..e9bf579c94a81d --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512BitAlg_VL_Vector256/ShuffleBits.cs @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using JIT.HardwareIntrinsics.X86; +using Xunit; + +namespace IntelHardwareIntrinsicTest._Avx512BitAlg_VL_Vector256 +{ + public partial class Program + { + [Fact] + public static unsafe void ShuffleBitsVector256() + { + if (!Avx512BitAlg.VL.IsSupported) + return; + + ulong[] value = new ulong[Vector256.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector256.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleBinaryOpTest__DataTable(value, control, new byte[32], 32); + + Vector256 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector256 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector256 actual = Avx512BitAlg.VL.ShuffleBits(op1, op2); + + for (int i = 0; i < Vector256.Count; ++i) + { + ulong qword_i = op1[i / 8]; + int idx_shift = op2[i] & 63; + ulong shufbit = (qword_i >> idx_shift) & 1ul; + byte expected = (byte)(shufbit == 1ul ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + + [Fact] + public static unsafe void MaskShuffleBitsVector256() + { + if (!Avx512BitAlg.VL.IsSupported) + return; + + byte[] mask = new byte[Vector256.Count]; + for (int i = 0; i < mask.Length; ++i) mask[i] = TestLibrary.Generator.GetByte(); + ulong[] value = new ulong[Vector256.Count]; + for (int i = 0; i < value.Length; ++i) value[i] = TestLibrary.Generator.GetUInt64(); + byte[] control = new byte[Vector256.Count]; + for (int i = 0; i < control.Length; ++i) control[i] = TestLibrary.Generator.GetByte(); + + using var table = new SimpleTernaryOpTest__DataTable(mask, value, control, new byte[32], 32); + + Vector256 op1 = Unsafe.Read>(table.inArray1Ptr); + Vector256 op2 = Unsafe.Read>(table.inArray2Ptr); + Vector256 op3 = Unsafe.Read>(table.inArray3Ptr); + Vector256 actual = Avx512BitAlg.VL.MaskShuffleBits(op1, op2, op3); + + for (int i = 0; i < Vector256.Count; ++i) + { + bool mask_i = (op1[i] & 0x80) == 0x80; + + ulong qword_i = op2[i / 8]; + int idx_shift = op3[i] & 63; + ulong shufbit = (qword_i >> idx_shift) & 1ul; + byte expected = (byte)((mask_i && shufbit == 1ul) ? 0xFF : 0x00); + Assert.Equal(expected, actual[i]); + } + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_r.csproj new file mode 100644 index 00000000000000..db8dfc59078058 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_ro.csproj new file mode 100644 index 00000000000000..f8987af0dcbbe4 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Avx512VPopcntDQ_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Program.Avx512VPopcntDQ.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Program.Avx512VPopcntDQ.cs new file mode 100644 index 00000000000000..56e22fde153a8d --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ/Program.Avx512VPopcntDQ.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512VPopcntDQ +{ + public static partial class Program + { + static Program() + { + + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_r.csproj new file mode 100644 index 00000000000000..49fed169a0dfd6 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_VL_Vector128_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_ro.csproj new file mode 100644 index 00000000000000..4ebf3759ca48eb --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Avx512VPopcntDQ_VL_Vector128_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_VL_Vector128_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Program.Avx512VPopcntDQ_VL_Vector128.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Program.Avx512VPopcntDQ_VL_Vector128.cs new file mode 100644 index 00000000000000..94dda506997a0c --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector128/Program.Avx512VPopcntDQ_VL_Vector128.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512VPopcntDQ_VL_Vector128 +{ + public static partial class Program + { + static Program() + { + + } + } +} diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_r.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_r.csproj new file mode 100644 index 00000000000000..b0dc4931b511ac --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_r.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_VL_Vector256_r + true + + + Embedded + + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_ro.csproj b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_ro.csproj new file mode 100644 index 00000000000000..57e8b6262d5ca4 --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Avx512VPopcntDQ_VL_Vector256_ro.csproj @@ -0,0 +1,14 @@ + + + X86_Avx512VPopcntDQ_VL_Vector256_ro + true + + + Embedded + True + + + + + + diff --git a/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Program.Avx512VPopcntDQ_VL_Vector256.cs b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Program.Avx512VPopcntDQ_VL_Vector256.cs new file mode 100644 index 00000000000000..de2cff2af9719a --- /dev/null +++ b/src/tests/JIT/HardwareIntrinsics/X86_Avx512/Avx512VPopcntDQ_VL_Vector256/Program.Avx512VPopcntDQ_VL_Vector256.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86._Avx512VPopcntDQ_VL_Vector256 +{ + public static partial class Program + { + static Program() + { + + } + } +}