Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VPCLMULQDQ intrinsics #109137

Merged
merged 20 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableBMI2, W("EnableBMI2"),
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableFMA, W("EnableFMA"), 1, "Allows FMA+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableLZCNT, W("EnableLZCNT"), 1, "Allows LZCNT+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnablePCLMULQDQ, W("EnablePCLMULQDQ"), 1, "Allows PCLMULQDQ+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableVPCLMULQDQ, W("EnableVPCLMULQDQ"), 1, "Allows VPCLMULQDQ+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableMOVBE, W("EnableMOVBE"), 1, "Allows MOVBE+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnablePOPCNT, W("EnablePOPCNT"), 1, "Allows POPCNT+ hardware intrinsics to be disabled")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableSSE, W("EnableSSE"), 1, "Allows SSE+ hardware intrinsics to be disabled")
Expand Down
216 changes: 114 additions & 102 deletions src/coreclr/inc/corinfoinstructionset.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,49 +58,49 @@ enum CORINFO_InstructionSet
InstructionSet_FMA=13,
InstructionSet_LZCNT=14,
InstructionSet_PCLMULQDQ=15,
InstructionSet_POPCNT=16,
InstructionSet_Vector128=17,
InstructionSet_Vector256=18,
InstructionSet_Vector512=19,
InstructionSet_AVXVNNI=20,
InstructionSet_MOVBE=21,
InstructionSet_X86Serialize=22,
InstructionSet_EVEX=23,
InstructionSet_AVX512F=24,
InstructionSet_AVX512F_VL=25,
InstructionSet_AVX512BW=26,
InstructionSet_AVX512BW_VL=27,
InstructionSet_AVX512CD=28,
InstructionSet_AVX512CD_VL=29,
InstructionSet_AVX512DQ=30,
InstructionSet_AVX512DQ_VL=31,
InstructionSet_AVX512VBMI=32,
InstructionSet_AVX512VBMI_VL=33,
InstructionSet_AVX10v1=34,
InstructionSet_AVX10v1_V512=35,
InstructionSet_VectorT128=36,
InstructionSet_VectorT256=37,
InstructionSet_VectorT512=38,
InstructionSet_X86Base_X64=39,
InstructionSet_SSE_X64=40,
InstructionSet_SSE2_X64=41,
InstructionSet_SSE3_X64=42,
InstructionSet_SSSE3_X64=43,
InstructionSet_SSE41_X64=44,
InstructionSet_SSE42_X64=45,
InstructionSet_AVX_X64=46,
InstructionSet_AVX2_X64=47,
InstructionSet_AES_X64=48,
InstructionSet_BMI1_X64=49,
InstructionSet_BMI2_X64=50,
InstructionSet_FMA_X64=51,
InstructionSet_LZCNT_X64=52,
InstructionSet_PCLMULQDQ_X64=53,
InstructionSet_POPCNT_X64=54,
InstructionSet_AVXVNNI_X64=55,
InstructionSet_MOVBE_X64=56,
InstructionSet_X86Serialize_X64=57,
InstructionSet_EVEX_X64=58,
InstructionSet_PCLMULQDQ_V256=16,
InstructionSet_PCLMULQDQ_V512=17,
InstructionSet_POPCNT=18,
InstructionSet_Vector128=19,
InstructionSet_Vector256=20,
InstructionSet_Vector512=21,
InstructionSet_AVXVNNI=22,
InstructionSet_MOVBE=23,
InstructionSet_X86Serialize=24,
InstructionSet_EVEX=25,
InstructionSet_AVX512F=26,
InstructionSet_AVX512F_VL=27,
InstructionSet_AVX512BW=28,
InstructionSet_AVX512BW_VL=29,
InstructionSet_AVX512CD=30,
InstructionSet_AVX512CD_VL=31,
InstructionSet_AVX512DQ=32,
InstructionSet_AVX512DQ_VL=33,
InstructionSet_AVX512VBMI=34,
InstructionSet_AVX512VBMI_VL=35,
InstructionSet_AVX10v1=36,
InstructionSet_AVX10v1_V512=37,
InstructionSet_VectorT128=38,
InstructionSet_VectorT256=39,
InstructionSet_VectorT512=40,
InstructionSet_X86Base_X64=41,
InstructionSet_SSE_X64=42,
InstructionSet_SSE2_X64=43,
InstructionSet_SSE3_X64=44,
InstructionSet_SSSE3_X64=45,
InstructionSet_SSE41_X64=46,
InstructionSet_SSE42_X64=47,
InstructionSet_AVX_X64=48,
InstructionSet_AVX2_X64=49,
InstructionSet_AES_X64=50,
InstructionSet_BMI1_X64=51,
InstructionSet_BMI2_X64=52,
InstructionSet_FMA_X64=53,
InstructionSet_LZCNT_X64=54,
InstructionSet_PCLMULQDQ_X64=55,
InstructionSet_POPCNT_X64=56,
InstructionSet_AVXVNNI_X64=57,
InstructionSet_X86Serialize_X64=58,
InstructionSet_AVX512F_X64=59,
InstructionSet_AVX512BW_X64=60,
InstructionSet_AVX512CD_X64=61,
Expand All @@ -125,49 +125,49 @@ enum CORINFO_InstructionSet
InstructionSet_FMA=13,
InstructionSet_LZCNT=14,
InstructionSet_PCLMULQDQ=15,
InstructionSet_POPCNT=16,
InstructionSet_Vector128=17,
InstructionSet_Vector256=18,
InstructionSet_Vector512=19,
InstructionSet_AVXVNNI=20,
InstructionSet_MOVBE=21,
InstructionSet_X86Serialize=22,
InstructionSet_EVEX=23,
InstructionSet_AVX512F=24,
InstructionSet_AVX512F_VL=25,
InstructionSet_AVX512BW=26,
InstructionSet_AVX512BW_VL=27,
InstructionSet_AVX512CD=28,
InstructionSet_AVX512CD_VL=29,
InstructionSet_AVX512DQ=30,
InstructionSet_AVX512DQ_VL=31,
InstructionSet_AVX512VBMI=32,
InstructionSet_AVX512VBMI_VL=33,
InstructionSet_AVX10v1=34,
InstructionSet_AVX10v1_V512=35,
InstructionSet_VectorT128=36,
InstructionSet_VectorT256=37,
InstructionSet_VectorT512=38,
InstructionSet_X86Base_X64=39,
InstructionSet_SSE_X64=40,
InstructionSet_SSE2_X64=41,
InstructionSet_SSE3_X64=42,
InstructionSet_SSSE3_X64=43,
InstructionSet_SSE41_X64=44,
InstructionSet_SSE42_X64=45,
InstructionSet_AVX_X64=46,
InstructionSet_AVX2_X64=47,
InstructionSet_AES_X64=48,
InstructionSet_BMI1_X64=49,
InstructionSet_BMI2_X64=50,
InstructionSet_FMA_X64=51,
InstructionSet_LZCNT_X64=52,
InstructionSet_PCLMULQDQ_X64=53,
InstructionSet_POPCNT_X64=54,
InstructionSet_AVXVNNI_X64=55,
InstructionSet_MOVBE_X64=56,
InstructionSet_X86Serialize_X64=57,
InstructionSet_EVEX_X64=58,
InstructionSet_PCLMULQDQ_V256=16,
InstructionSet_PCLMULQDQ_V512=17,
InstructionSet_POPCNT=18,
InstructionSet_Vector128=19,
InstructionSet_Vector256=20,
InstructionSet_Vector512=21,
InstructionSet_AVXVNNI=22,
InstructionSet_MOVBE=23,
InstructionSet_X86Serialize=24,
InstructionSet_EVEX=25,
InstructionSet_AVX512F=26,
InstructionSet_AVX512F_VL=27,
InstructionSet_AVX512BW=28,
InstructionSet_AVX512BW_VL=29,
InstructionSet_AVX512CD=30,
InstructionSet_AVX512CD_VL=31,
InstructionSet_AVX512DQ=32,
InstructionSet_AVX512DQ_VL=33,
InstructionSet_AVX512VBMI=34,
InstructionSet_AVX512VBMI_VL=35,
InstructionSet_AVX10v1=36,
InstructionSet_AVX10v1_V512=37,
InstructionSet_VectorT128=38,
InstructionSet_VectorT256=39,
InstructionSet_VectorT512=40,
InstructionSet_X86Base_X64=41,
InstructionSet_SSE_X64=42,
InstructionSet_SSE2_X64=43,
InstructionSet_SSE3_X64=44,
InstructionSet_SSSE3_X64=45,
InstructionSet_SSE41_X64=46,
InstructionSet_SSE42_X64=47,
InstructionSet_AVX_X64=48,
InstructionSet_AVX2_X64=49,
InstructionSet_AES_X64=50,
InstructionSet_BMI1_X64=51,
InstructionSet_BMI2_X64=52,
InstructionSet_FMA_X64=53,
InstructionSet_LZCNT_X64=54,
InstructionSet_PCLMULQDQ_X64=55,
InstructionSet_POPCNT_X64=56,
InstructionSet_AVXVNNI_X64=57,
InstructionSet_X86Serialize_X64=58,
InstructionSet_AVX512F_X64=59,
InstructionSet_AVX512BW_X64=60,
InstructionSet_AVX512CD_X64=61,
Expand Down Expand Up @@ -324,12 +324,8 @@ struct CORINFO_InstructionSetFlags
AddInstructionSet(InstructionSet_POPCNT_X64);
if (HasInstructionSet(InstructionSet_AVXVNNI))
AddInstructionSet(InstructionSet_AVXVNNI_X64);
if (HasInstructionSet(InstructionSet_MOVBE))
AddInstructionSet(InstructionSet_MOVBE_X64);
if (HasInstructionSet(InstructionSet_X86Serialize))
AddInstructionSet(InstructionSet_X86Serialize_X64);
if (HasInstructionSet(InstructionSet_EVEX))
AddInstructionSet(InstructionSet_EVEX_X64);
if (HasInstructionSet(InstructionSet_AVX512F))
AddInstructionSet(InstructionSet_AVX512F_X64);
if (HasInstructionSet(InstructionSet_AVX512BW))
Expand Down Expand Up @@ -492,18 +488,10 @@ inline CORINFO_InstructionSetFlags EnsureInstructionSetFlagsAreValid(CORINFO_Ins
resultflags.RemoveInstructionSet(InstructionSet_AVXVNNI);
if (resultflags.HasInstructionSet(InstructionSet_AVXVNNI_X64) && !resultflags.HasInstructionSet(InstructionSet_AVXVNNI))
resultflags.RemoveInstructionSet(InstructionSet_AVXVNNI_X64);
if (resultflags.HasInstructionSet(InstructionSet_MOVBE) && !resultflags.HasInstructionSet(InstructionSet_MOVBE_X64))
resultflags.RemoveInstructionSet(InstructionSet_MOVBE);
if (resultflags.HasInstructionSet(InstructionSet_MOVBE_X64) && !resultflags.HasInstructionSet(InstructionSet_MOVBE))
resultflags.RemoveInstructionSet(InstructionSet_MOVBE_X64);
if (resultflags.HasInstructionSet(InstructionSet_X86Serialize) && !resultflags.HasInstructionSet(InstructionSet_X86Serialize_X64))
resultflags.RemoveInstructionSet(InstructionSet_X86Serialize);
if (resultflags.HasInstructionSet(InstructionSet_X86Serialize_X64) && !resultflags.HasInstructionSet(InstructionSet_X86Serialize))
resultflags.RemoveInstructionSet(InstructionSet_X86Serialize_X64);
if (resultflags.HasInstructionSet(InstructionSet_EVEX) && !resultflags.HasInstructionSet(InstructionSet_EVEX_X64))
resultflags.RemoveInstructionSet(InstructionSet_EVEX);
if (resultflags.HasInstructionSet(InstructionSet_EVEX_X64) && !resultflags.HasInstructionSet(InstructionSet_EVEX))
resultflags.RemoveInstructionSet(InstructionSet_EVEX_X64);
if (resultflags.HasInstructionSet(InstructionSet_AVX512F) && !resultflags.HasInstructionSet(InstructionSet_AVX512F_X64))
resultflags.RemoveInstructionSet(InstructionSet_AVX512F);
if (resultflags.HasInstructionSet(InstructionSet_AVX512F_X64) && !resultflags.HasInstructionSet(InstructionSet_AVX512F))
Expand Down Expand Up @@ -596,6 +584,14 @@ inline CORINFO_InstructionSetFlags EnsureInstructionSetFlagsAreValid(CORINFO_Ins
resultflags.RemoveInstructionSet(InstructionSet_AES);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256) && !resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V256);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256) && !resultflags.HasInstructionSet(InstructionSet_AVX))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V256);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V512) && !resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V512);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V512) && !resultflags.HasInstructionSet(InstructionSet_AVX512F))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V512);
if (resultflags.HasInstructionSet(InstructionSet_AVXVNNI) && !resultflags.HasInstructionSet(InstructionSet_AVX2))
resultflags.RemoveInstructionSet(InstructionSet_AVXVNNI);
if (resultflags.HasInstructionSet(InstructionSet_X86Serialize) && !resultflags.HasInstructionSet(InstructionSet_X86Base))
Expand Down Expand Up @@ -702,6 +698,14 @@ inline CORINFO_InstructionSetFlags EnsureInstructionSetFlagsAreValid(CORINFO_Ins
resultflags.RemoveInstructionSet(InstructionSet_AES);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ) && !resultflags.HasInstructionSet(InstructionSet_SSE2))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256) && !resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V256);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256) && !resultflags.HasInstructionSet(InstructionSet_AVX))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V256);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V512) && !resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V256))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V512);
if (resultflags.HasInstructionSet(InstructionSet_PCLMULQDQ_V512) && !resultflags.HasInstructionSet(InstructionSet_AVX512F))
resultflags.RemoveInstructionSet(InstructionSet_PCLMULQDQ_V512);
if (resultflags.HasInstructionSet(InstructionSet_AVXVNNI) && !resultflags.HasInstructionSet(InstructionSet_AVX2))
resultflags.RemoveInstructionSet(InstructionSet_AVXVNNI);
if (resultflags.HasInstructionSet(InstructionSet_X86Serialize) && !resultflags.HasInstructionSet(InstructionSet_X86Base))
Expand Down Expand Up @@ -870,6 +874,10 @@ inline const char *InstructionSetToString(CORINFO_InstructionSet instructionSet)
return "PCLMULQDQ";
case InstructionSet_PCLMULQDQ_X64 :
return "PCLMULQDQ_X64";
case InstructionSet_PCLMULQDQ_V256 :
return "PCLMULQDQ_V256";
case InstructionSet_PCLMULQDQ_V512 :
return "PCLMULQDQ_V512";
case InstructionSet_POPCNT :
return "POPCNT";
case InstructionSet_POPCNT_X64 :
Expand All @@ -886,16 +894,12 @@ inline const char *InstructionSetToString(CORINFO_InstructionSet instructionSet)
return "AVXVNNI_X64";
case InstructionSet_MOVBE :
return "MOVBE";
case InstructionSet_MOVBE_X64 :
return "MOVBE_X64";
case InstructionSet_X86Serialize :
return "X86Serialize";
case InstructionSet_X86Serialize_X64 :
return "X86Serialize_X64";
case InstructionSet_EVEX :
return "EVEX";
case InstructionSet_EVEX_X64 :
return "EVEX_X64";
case InstructionSet_AVX512F :
return "AVX512F";
case InstructionSet_AVX512F_X64 :
Expand Down Expand Up @@ -972,6 +976,10 @@ inline const char *InstructionSetToString(CORINFO_InstructionSet instructionSet)
return "LZCNT";
case InstructionSet_PCLMULQDQ :
return "PCLMULQDQ";
case InstructionSet_PCLMULQDQ_V256 :
return "PCLMULQDQ_V256";
case InstructionSet_PCLMULQDQ_V512 :
return "PCLMULQDQ_V512";
case InstructionSet_POPCNT :
return "POPCNT";
case InstructionSet_Vector128 :
Expand Down Expand Up @@ -1068,6 +1076,8 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst
case READYTORUN_INSTRUCTION_Fma: return InstructionSet_FMA;
case READYTORUN_INSTRUCTION_Lzcnt: return InstructionSet_LZCNT;
case READYTORUN_INSTRUCTION_Pclmulqdq: return InstructionSet_PCLMULQDQ;
case READYTORUN_INSTRUCTION_Pclmulqdq_V256: return InstructionSet_PCLMULQDQ_V256;
case READYTORUN_INSTRUCTION_Pclmulqdq_V512: return InstructionSet_PCLMULQDQ_V512;
case READYTORUN_INSTRUCTION_Popcnt: return InstructionSet_POPCNT;
case READYTORUN_INSTRUCTION_AvxVnni: return InstructionSet_AVXVNNI;
case READYTORUN_INSTRUCTION_Movbe: return InstructionSet_MOVBE;
Expand Down Expand Up @@ -1105,6 +1115,8 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst
case READYTORUN_INSTRUCTION_Fma: return InstructionSet_FMA;
case READYTORUN_INSTRUCTION_Lzcnt: return InstructionSet_LZCNT;
case READYTORUN_INSTRUCTION_Pclmulqdq: return InstructionSet_PCLMULQDQ;
case READYTORUN_INSTRUCTION_Pclmulqdq_V256: return InstructionSet_PCLMULQDQ_V256;
case READYTORUN_INSTRUCTION_Pclmulqdq_V512: return InstructionSet_PCLMULQDQ_V512;
case READYTORUN_INSTRUCTION_Popcnt: return InstructionSet_POPCNT;
case READYTORUN_INSTRUCTION_AvxVnni: return InstructionSet_AVXVNNI;
case READYTORUN_INSTRUCTION_Movbe: return InstructionSet_MOVBE;
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 04021b93-e969-41ed-96cd-4c583673b9ab */
0x04021b93,
0xe969,
0x41ed,
{0x96, 0xcd, 0x4c, 0x58, 0x36, 0x73, 0xb9, 0xab}
constexpr GUID JITEEVersionIdentifier = { /* 9014d652-5dc7-4edf-9285-6644d0898fb5 */
0x9014d652,
0x5dc7,
0x4edf,
{0x92, 0x85, 0x66, 0x44, 0xd0, 0x89, 0x8f, 0xb5}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/readytoruninstructionset.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ enum ReadyToRunInstructionSet
READYTORUN_INSTRUCTION_Avx10v1=44,
READYTORUN_INSTRUCTION_Avx10v1_V512=46,
READYTORUN_INSTRUCTION_EVEX=47,
READYTORUN_INSTRUCTION_Pclmulqdq_V256=48,
READYTORUN_INSTRUCTION_Pclmulqdq_V512=49,

};

Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6171,6 +6171,12 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
instructionSetFlags.AddInstructionSet(InstructionSet_PCLMULQDQ);
}

if (JitConfig.EnableVPCLMULQDQ() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_PCLMULQDQ_V256);
instructionSetFlags.AddInstructionSet(InstructionSet_PCLMULQDQ_V512);
}

if (JitConfig.EnablePOPCNT() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_POPCNT);
Expand Down
14 changes: 13 additions & 1 deletion src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,19 @@ bool emitter::IsEvexEncodableInstruction(instruction ins) const
{
return false;
}
return HasEvexEncoding(ins);

switch (ins)
{
case INS_pclmulqdq:
saucecontrol marked this conversation as resolved.
Show resolved Hide resolved
{
return emitComp->compOpportunisticallyDependsOn(InstructionSet_PCLMULQDQ_V256);
}

default:
{
return HasEvexEncoding(ins);
}
}
}

//------------------------------------------------------------------------
Expand Down
Loading
Loading