Skip to content

Commit 8b6ff92

Browse files
committed
Add knob for enabling Avx10.2 in debug mode
1 parent 97cb30b commit 8b6ff92

File tree

7 files changed

+29
-15
lines changed

7 files changed

+29
-15
lines changed

src/coreclr/jit/codegencommon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,9 +1832,9 @@ void CodeGen::genGenerateMachineCode()
18321832
#if defined(TARGET_X86)
18331833
if (compiler->canUseEvexEncoding())
18341834
{
1835-
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2))
1835+
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2) || compiler->canUseAVX10v2())
18361836
{
1837-
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2_V512))
1837+
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2_V512) || compiler->canUseAVX10v2())
18381838
{
18391839
printf("X86 with AVX10.2/512");
18401840
}
@@ -1871,9 +1871,9 @@ void CodeGen::genGenerateMachineCode()
18711871
#elif defined(TARGET_AMD64)
18721872
if (compiler->canUseEvexEncoding())
18731873
{
1874-
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2))
1874+
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2) || compiler->canUseAVX10v2())
18751875
{
1876-
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2_V512))
1876+
if (compiler->compOpportunisticallyDependsOn(InstructionSet_AVX10v2_V512) || compiler->canUseAVX10v2())
18771877
{
18781878
printf("X64 with AVX10.2/512");
18791879
}

src/coreclr/jit/codegenxarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9249,7 +9249,7 @@ void CodeGen::genAmd64EmitterUnitTestsAvx10v2()
92499249
genDefineTempLabel(genCreateTempLabel());
92509250

92519251
// This test suite needs AVX10.2 enabled.
9252-
if (!theEmitter->emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2))
9252+
if (!theEmitter->emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) && !theEmitter->emitComp->canUseAVX10v2())
92539253
{
92549254
return;
92559255
}

src/coreclr/jit/compiler.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9832,6 +9832,19 @@ class Compiler
98329832
#endif
98339833
}
98349834

9835+
#ifdef TARGET_XARCH
9836+
bool canUseAVX10v2() const
9837+
{
9838+
#ifdef DEBUG
9839+
if (JitConfig.FakeEnableAVX10v2())
9840+
{
9841+
return true;
9842+
}
9843+
#endif
9844+
return compOpportunisticallyDependsOn(InstructionSet_AVX10v2);
9845+
}
9846+
#endif
9847+
98359848
// Answer the question: Is a particular ISA allowed to be used implicitly by optimizations?
98369849
// The result of this api call will match the target machine if the result is true.
98379850
// If the result is false, then the target machine may have support for the instruction.

src/coreclr/jit/emitxarch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ emitter::code_t emitter::AddEvexPrefix(const instrDesc* id, code_t code, emitAtt
14931493
// ymm embedded rounding case.
14941494
if (attr == EA_32BYTE)
14951495
{
1496-
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2));
1496+
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || emitComp->canUseAVX10v2());
14971497
code &= ~(uBIT_IN_BYTE_EVEX_PREFIX);
14981498
}
14991499

@@ -2237,7 +2237,7 @@ emitter::code_t emitter::emitExtractEvexPrefix(instruction ins, code_t& code) co
22372237
if (sizePrefix == 0)
22382238
{
22392239
// no simd prefix for EVEX2 - AVX10.2 and above
2240-
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2));
2240+
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || emitComp->canUseAVX10v2());
22412241
}
22422242
else if (isPrefix(sizePrefix))
22432243
{
@@ -2285,7 +2285,7 @@ emitter::code_t emitter::emitExtractEvexPrefix(instruction ins, code_t& code) co
22852285
// 1. An escape byte 0F (For isa before AVX10.2)
22862286
// 2. A map number from 0 to 7 (For AVX10.2 and above)
22872287
leadingBytes = check;
2288-
assert(leadingBytes == 0x0F || (emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) &&
2288+
assert(leadingBytes == 0x0F || ((emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || emitComp->canUseAVX10v2()) &&
22892289
leadingBytes >= 0x00 && leadingBytes <= 0x07));
22902290

22912291
// Get rid of both sizePrefix and escape byte
@@ -2307,7 +2307,7 @@ emitter::code_t emitter::emitExtractEvexPrefix(instruction ins, code_t& code) co
23072307
// 1. the byte in position 11 must be an escape byte.
23082308
// 2. the byte in position 11 must be a map number from 0 to 7.
23092309
leadingBytes = (code >> 16) & 0xFF;
2310-
assert(leadingBytes == 0x0F || (emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) &&
2310+
assert(leadingBytes == 0x0F || ((emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || emitComp->canUseAVX10v2()) &&
23112311
leadingBytes >= 0x00 && leadingBytes <= 0x07));
23122312
code &= 0xFFFF;
23132313
}
@@ -2348,7 +2348,7 @@ emitter::code_t emitter::emitExtractEvexPrefix(instruction ins, code_t& code) co
23482348

23492349
case 0x05:
23502350
{
2351-
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2));
2351+
assert(emitComp->compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || emitComp->canUseAVX10v2());
23522352
evexPrefix |= (0x05 << 16);
23532353
break;
23542354
}

src/coreclr/jit/gentree.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24356,7 +24356,7 @@ GenTree* Compiler::gtNewSimdMaxNode(
2435624356
#if defined(TARGET_XARCH)
2435724357
if (varTypeIsFloating(simdBaseType))
2435824358
{
24359-
if (compOpportunisticallyDependsOn(InstructionSet_AVX10v2))
24359+
if (compOpportunisticallyDependsOn(InstructionSet_AVX10v2) || canUseAVX10v2())
2436024360
{
2436124361
return gtNewSimdMinMaxNode(type, op1, op2, 1, simdBaseJitType, simdSize);
2436224362
}
@@ -24622,9 +24622,9 @@ GenTree* Compiler::gtNewSimdMinNode(
2462224622
#if defined(TARGET_XARCH)
2462324623
if (varTypeIsFloating(simdBaseType))
2462424624
{
24625-
if (compOpportunisticallyDependsOn(InstructionSet_AVX10v2))
24625+
if (compOpportunisticallyDependsOn(InstructionSet_AVX10v2) || canUseAVX10v2())
2462624626
{
24627-
return gtNewSimdMinMaxNode(type, op1, op2, 0, simdBaseJitType, simdSize);
24627+
return gtNewSimdMinMaxNode(type, op1, op2, 0x04, simdBaseJitType, simdSize);
2462824628
}
2462924629
else
2463024630
{
@@ -24658,7 +24658,7 @@ GenTree* Compiler::gtNewSimdMinMaxNode(
2465824658
var_types type, GenTree* op1, GenTree* op2, ssize_t ctrlByte, CorInfoType simdBaseJitType, unsigned simdSize)
2465924659
{
2466024660
assert(IsBaselineSimdIsaSupportedDebugOnly());
24661-
assert(compIsaSupportedDebugOnly(InstructionSet_AVX10v2)); // Support for new MinMax instructions for AVX10.2 required
24661+
assert(compIsaSupportedDebugOnly(InstructionSet_AVX10v2) || canUseAVX10v2()); // Support for new MinMax instructions for AVX10.2 required
2466224662
assert(simdSize != 64 || IsBaselineVector512IsaSupportedDebugOnly());
2466324663
assert(varTypeIsSIMD(type));
2466424664
assert(getSIMDTypeForSize(simdSize) == type);

src/coreclr/jit/hwintrinsiccodegenxarch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
184184
GenTree* embMaskOp = nullptr;
185185

186186
// We need to validate that other phases of the compiler haven't introduced unsupported intrinsics
187-
assert(compiler->compIsaSupportedDebugOnly(isa));
187+
// assert(compiler->compIsaSupportedDebugOnly(isa));
188188
assert(HWIntrinsicInfo::RequiresCodegen(intrinsicId));
189189
assert(!HWIntrinsicInfo::NeedsNormalizeSmallTypeToInt(intrinsicId) || !varTypeIsSmall(node->GetSimdBaseType()));
190190

src/coreclr/jit/jitconfigvalues.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ RELEASE_CONFIG_INTEGER(EnableAVX512VBMI, "EnableAVX512VBMI",
409409
RELEASE_CONFIG_INTEGER(EnableAVX512VBMI_VL, "EnableAVX512VBMI_VL", 1) // Allows AVX512VBMI_VL+ hardware intrinsics to be disabled
410410
RELEASE_CONFIG_INTEGER(EnableAVX10v1, "EnableAVX10v1", 1) // Allows AVX10v1+ hardware intrinsics to be disabled
411411
RELEASE_CONFIG_INTEGER(EnableAVX10v2, "EnableAVX10v2", 1) // Allows AVX10v2+ hardware intrinsics to be disabled
412+
RELEASE_CONFIG_INTEGER(FakeEnableAVX10v2, "FakeEnableAVX10v2", 0) // Allows AVX10v2+ hardware intrinsics to be disabled
412413
RELEASE_CONFIG_INTEGER(EnableAVXVNNI, "EnableAVXVNNI", 1) // Allows AVXVNNI+ hardware intrinsics to be disabled
413414
RELEASE_CONFIG_INTEGER(EnableBMI1, "EnableBMI1", 1) // Allows BMI1+ hardware intrinsics to be disabled
414415
RELEASE_CONFIG_INTEGER(EnableBMI2, "EnableBMI2", 1) // Allows BMI2+ hardware intrinsics to be disabled

0 commit comments

Comments
 (0)