Skip to content

Commit

Permalink
Revert "Enable EVEX support by default (#83648)"
Browse files Browse the repository at this point in the history
This reverts commit c6cc201.
  • Loading branch information
jkotas authored Mar 25, 2023
1 parent 91b93eb commit 39b10b6
Show file tree
Hide file tree
Showing 17 changed files with 277 additions and 338 deletions.
13 changes: 2 additions & 11 deletions eng/pipelines/common/templates/runtimes/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,9 @@ jobs:
- jitstress_isas_nohwintrinsic
- jitstress_isas_nohwintrinsic_nosimd
- jitstress_isas_nosimd
- jitstress_isas_x86_evex
- jitstress_isas_x86_noaes
- jitstress_isas_x86_noavx
- jitstress_isas_x86_noavx2
- jitstress_isas_x86_noavx512
- jitstress_isas_x86_nobmi1
- jitstress_isas_x86_nobmi2
- jitstress_isas_x86_nofma
Expand All @@ -429,7 +427,6 @@ jobs:
- jitstress_isas_1_x86_noaes
- jitstress_isas_1_x86_noavx
- jitstress_isas_1_x86_noavx2
- jitstress_isas_1_x86_noavx512
- jitstress_isas_1_x86_nobmi1
- jitstress_isas_1_x86_nobmi2
- jitstress_isas_1_x86_nofma
Expand All @@ -447,7 +444,6 @@ jobs:
- jitstress_isas_2_x86_noaes
- jitstress_isas_2_x86_noavx
- jitstress_isas_2_x86_noavx2
- jitstress_isas_2_x86_noavx512
- jitstress_isas_2_x86_nobmi1
- jitstress_isas_2_x86_nobmi2
- jitstress_isas_2_x86_nofma
Expand All @@ -464,9 +460,8 @@ jobs:
- jitstress_isas_2_x86_nossse3
${{ if in(parameters.testGroup, 'jitstress-isas-avx512') }}:
scenarios:
- jitstress_isas_x86_evex
- jitstress_isas_x86_noavx512
- jitstressregs0x2000
- jitstress_isas_avx512_forceevex
- jitstress_isas_avx512_forceevex_stresshighregs
${{ if in(parameters.testGroup, 'jitstressregs-x86') }}:
scenarios:
- jitstressregs1_x86_noavx
Expand All @@ -477,7 +472,6 @@ jobs:
- jitstressregs0x10_x86_noavx
- jitstressregs0x80_x86_noavx
- jitstressregs0x1000_x86_noavx
- jitstressregs0x2000_x86_noavx
${{ if in(parameters.testGroup, 'jitstressregs' ) }}:
scenarios:
- jitstressregs1
Expand All @@ -488,7 +482,6 @@ jobs:
- jitstressregs0x10
- jitstressregs0x80
- jitstressregs0x1000
- jitstressregs0x2000
${{ if in(parameters.testGroup, 'jitstress2-jitstressregs') }}:
scenarios:
- jitstress2_jitstressregs1
Expand All @@ -499,7 +492,6 @@ jobs:
- jitstress2_jitstressregs0x10
- jitstress2_jitstressregs0x80
- jitstress2_jitstressregs0x1000
- jitstress2_jitstressregs0x2000
${{ if in(parameters.testGroup, 'gcstress0x3-gcstress0xc') }}:
scenarios:
- gcstress0x3
Expand Down Expand Up @@ -528,7 +520,6 @@ jobs:
- jitstressregs0x10
- jitstressregs0x80
- jitstressregs0x1000
- jitstressregs0x2000
- jitminopts
- forcerelocs
- gcstress0xc
Expand Down
2 changes: 0 additions & 2 deletions eng/pipelines/libraries/run-test-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ jobs:
- jitstressregs0x10
- jitstressregs0x80
- jitstressregs0x1000
- jitstressregs0x2000
${{ if in(parameters.coreclrTestGroup, 'jitstress2-jitstressregs') }}:
scenarios:
- jitstress2_jitstressregs1
Expand All @@ -172,7 +171,6 @@ jobs:
- jitstress2_jitstressregs0x10
- jitstress2_jitstressregs0x80
- jitstress2_jitstressregs0x1000
- jitstress2_jitstressregs0x2000
${{ if in(parameters.coreclrTestGroup, 'gcstress0x3-gcstress0xc') }}:
scenarios:
# Disable gcstress0x3 for now; it causes lots of test timeouts. Investigate this after
Expand Down
125 changes: 49 additions & 76 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2275,51 +2275,64 @@ void Compiler::compSetProcessor()
{
instructionSetFlags.AddInstructionSet(InstructionSet_Vector128);
}

if (instructionSetFlags.HasInstructionSet(InstructionSet_AVX))
{
instructionSetFlags.AddInstructionSet(InstructionSet_Vector256);
}
// x86-64-v4 feature level supports AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL and
// AVX512F/AVX512BW/AVX512CD/AVX512DQ/VX512VL have been shipped together historically.
// It is therefore unlikely that future CPUs only support "just one" and
// not worth the additional complexity in the JIT to support.
if (instructionSetFlags.HasInstructionSet(InstructionSet_AVX512F) &&
instructionSetFlags.HasInstructionSet(InstructionSet_AVX512BW) &&
instructionSetFlags.HasInstructionSet(InstructionSet_AVX512DQ))
{
// Using JitStressEVEXEncoding flag will force instructions which would
// otherwise use VEX encoding but can be EVEX encoded to use EVEX encoding
// This requires AVX512VL support. JitForceEVEXEncoding forces this encoding, thus
// causing failure if not running on compatible hardware.

// x86-64-v4 feature level supports AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL
// These have been shipped together historically and at the time of this writing
// there exists no hardware which doesn't support the entire feature set. To simplify
// the overall JIT implementation, we currently require the entire set of ISAs to be
// supported and disable AVX512 support otherwise.
// We can't use !DoJitStressEvexEncoding() yet because opts.compSupportsISA hasn't
// been set yet as that's what we're trying to set here

if (instructionSetFlags.HasInstructionSet(InstructionSet_AVX512BW_VL) &&
instructionSetFlags.HasInstructionSet(InstructionSet_AVX512CD_VL) &&
instructionSetFlags.HasInstructionSet(InstructionSet_AVX512DQ_VL))
{
assert(instructionSetFlags.HasInstructionSet(InstructionSet_AVX512BW));
assert(instructionSetFlags.HasInstructionSet(InstructionSet_AVX512CD));
assert(instructionSetFlags.HasInstructionSet(InstructionSet_AVX512DQ));
assert(instructionSetFlags.HasInstructionSet(InstructionSet_AVX512F));
assert(instructionSetFlags.HasInstructionSet(InstructionSet_AVX512F_VL));
bool enableAvx512 = false;

instructionSetFlags.AddInstructionSet(InstructionSet_Vector512);
}
else
{
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_VL);
#if defined(DEBUG)
if (JitConfig.JitForceEVEXEncoding())
{
enableAvx512 = true;
}
else if (JitConfig.JitStressEvexEncoding() && instructionSetFlags.HasInstructionSet(InstructionSet_AVX512F_VL))
{
enableAvx512 = true;
}
#endif // DEBUG

if (!enableAvx512)
{
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_VL);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_VL);
#ifdef TARGET_AMD64
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512F_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512BW_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512CD_VL_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_X64);
instructionSetFlags.RemoveInstructionSet(InstructionSet_AVX512DQ_VL_X64);
#endif // TARGET_AMD64
}
else
{
instructionSetFlags.AddInstructionSet(InstructionSet_Vector512);
}
}
#elif defined(TARGET_ARM64)
if (instructionSetFlags.HasInstructionSet(InstructionSet_AdvSimd))
Expand Down Expand Up @@ -3386,7 +3399,7 @@ void Compiler::compInitOptions(JitFlags* jitFlags)
rbmFltCalleeTrash = RBM_FLT_CALLEE_TRASH_INIT;
cntCalleeTrashFloat = CNT_CALLEE_TRASH_FLOAT_INIT;

if (canUseEvexEncoding())
if (DoJitStressEvexEncoding())
{
rbmAllFloat |= RBM_HIGHFLOAT;
rbmFltCalleeTrash |= RBM_HIGHFLOAT;
Expand Down Expand Up @@ -6015,46 +6028,6 @@ int Compiler::compCompile(CORINFO_MODULE_HANDLE classPtr,
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVXVNNI);
}

if (JitConfig.EnableAVX512F() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512F);
}

if (JitConfig.EnableAVX512F_VL() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512F_VL);
}

if (JitConfig.EnableAVX512BW() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512BW);
}

if (JitConfig.EnableAVX512BW_VL() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512BW_VL);
}

if (JitConfig.EnableAVX512CD() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512CD);
}

if (JitConfig.EnableAVX512CD_VL() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512CD_VL);
}

if (JitConfig.EnableAVX512DQ() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512DQ);
}

if (JitConfig.EnableAVX512DQ_VL() != 0)
{
instructionSetFlags.AddInstructionSet(InstructionSet_AVX512DQ_VL);
}
#endif

// These calls are important and explicitly ordered to ensure that the flags are correct in
Expand Down
35 changes: 23 additions & 12 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9175,7 +9175,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//
bool IsBaselineVector512IsaSupportedDebugOnly() const
{
#ifdef TARGET_XARCH
#ifdef TARGET_AMD64
return (compIsaSupportedDebugOnly(InstructionSet_Vector512));
#else
return false;
Expand All @@ -9191,7 +9191,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//
bool IsBaselineVector512IsaSupported() const
{
#ifdef TARGET_XARCH
#ifdef TARGET_AMD64
return (compExactlyDependsOn(InstructionSet_Vector512));
#else
return false;
Expand All @@ -9201,6 +9201,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#ifdef TARGET_XARCH
bool canUseVexEncoding() const
{
#ifdef DEBUG
if (JitConfig.JitForceEVEXEncoding())
{
return true;
}
#endif // DEBUG

return compOpportunisticallyDependsOn(InstructionSet_AVX);
}

Expand All @@ -9212,6 +9219,13 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//
bool canUseEvexEncoding() const
{
#ifdef DEBUG
if (JitConfig.JitForceEVEXEncoding())
{
return true;
}
#endif // DEBUG

return compOpportunisticallyDependsOn(InstructionSet_AVX512F);
}

Expand All @@ -9226,19 +9240,16 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#ifdef DEBUG
// Using JitStressEVEXEncoding flag will force instructions which would
// otherwise use VEX encoding but can be EVEX encoded to use EVEX encoding
// This requires AVX512F, AVX512BW, AVX512CD, AVX512DQ, and AVX512VL support
// This requires AVX512VL support. JitForceEVEXEncoding forces this encoding, thus
// causing failure if not running on compatible hardware.

if (JitConfig.JitStressEvexEncoding() && IsBaselineVector512IsaSupported())
if (JitConfig.JitForceEVEXEncoding())
{
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512F));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512F_VL));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512BW));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512BW_VL));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512CD));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512CD_VL));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512DQ));
assert(compIsaSupportedDebugOnly(InstructionSet_AVX512DQ_VL));
return true;
}

if (JitConfig.JitStressEvexEncoding() && compOpportunisticallyDependsOn(InstructionSet_AVX512F_VL))
{
return true;
}
#endif // DEBUG
Expand Down
11 changes: 3 additions & 8 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6591,7 +6591,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
coldCodeBlock = nullptr;

// This restricts the data alignment to: 4, 8, 16, 32 or 64 bytes
// Alignments greater than 64 would require VM support in ICorJitInfo::allocMem
// Alignments greater than 32 would require VM support in ICorJitInfo::allocMem
uint32_t dataAlignment = emitConsDsc.alignment;
assert((dataSection::MIN_DATA_ALIGN <= dataAlignment) && (dataAlignment <= dataSection::MAX_DATA_ALIGN) &&
isPow2(dataAlignment));
Expand Down Expand Up @@ -6710,16 +6710,11 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
{
assert(((size_t)codeBlock & 15) == 0);
}

if ((allocMemFlag & CORJIT_ALLOCMEM_FLG_RODATA_64BYTE_ALIGN) != 0)
{
assert(((size_t)consBlock & 63) == 0);
}
else if ((allocMemFlag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0)
if ((allocMemFlag & CORJIT_ALLOCMEM_FLG_RODATA_32BYTE_ALIGN) != 0)
{
assert(((size_t)consBlock & 31) == 0);
}
else if ((allocMemFlag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0)
if ((allocMemFlag & CORJIT_ALLOCMEM_FLG_RODATA_16BYTE_ALIGN) != 0)
{
assert(((size_t)consBlock & 15) == 0);
}
Expand Down
Loading

0 comments on commit 39b10b6

Please sign in to comment.