Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Updating the compiler to not enable FMA if the global AVX flag is dis…
Browse files Browse the repository at this point in the history
…abled.
  • Loading branch information
tannergooding committed May 25, 2018
1 parent 65f17b2 commit 8db778b
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2421,18 +2421,17 @@ static bool configEnableISA(InstructionSet isa)
return JitConfig.EnableSSE42() != 0;
case InstructionSet_AVX:
return JitConfig.EnableAVX() != 0;
case InstructionSet_FMA:
return JitConfig.EnableFMA() != 0;
case InstructionSet_AVX2:
// Don't enable AVX2 when AVX is disabled
return (JitConfig.EnableAVX() != 0) && (JitConfig.EnableAVX2() != 0);
return JitConfig.EnableAVX2() != 0;

case InstructionSet_AES:
return JitConfig.EnableAES() != 0;
case InstructionSet_BMI1:
return JitConfig.EnableBMI1() != 0;
case InstructionSet_BMI2:
return JitConfig.EnableBMI2() != 0;
case InstructionSet_FMA:
return JitConfig.EnableFMA() != 0;
case InstructionSet_LZCNT:
return JitConfig.EnableLZCNT() != 0;
case InstructionSet_PCLMULQDQ:
Expand All @@ -2443,8 +2442,8 @@ static bool configEnableISA(InstructionSet isa)
return false;
}
#else
// We have a retail config switch that can disable AVX/AVX2 instructions
if ((isa == InstructionSet_AVX) || (isa == InstructionSet_AVX2))
// We have a retail config switch that can disable AVX/FMA/AVX2 instructions
if ((isa == InstructionSet_AVX) || (isa == InstructionSet_FMA) || (isa == InstructionSet_AVX2))
{
return JitConfig.EnableAVX() != 0;
}
Expand Down Expand Up @@ -2513,22 +2512,6 @@ void Compiler::compSetProcessor()
opts.setSupportedISA(InstructionSet_AES);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX))
{
if (configEnableISA(InstructionSet_AVX))
{
opts.setSupportedISA(InstructionSet_AVX);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX2))
{
// COMPlus_EnableAVX is also used to control the code generation of
// System.Numerics.Vectors and floating-point arithmetics
if (configEnableISA(InstructionSet_AVX) && configEnableISA(InstructionSet_AVX2))
{
opts.setSupportedISA(InstructionSet_AVX2);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI1))
{
if (configEnableISA(InstructionSet_BMI1))
Expand All @@ -2543,13 +2526,6 @@ void Compiler::compSetProcessor()
opts.setSupportedISA(InstructionSet_BMI2);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_FMA))
{
if (configEnableISA(InstructionSet_FMA))
{
opts.setSupportedISA(InstructionSet_FMA);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_LZCNT))
{
if (configEnableISA(InstructionSet_LZCNT))
Expand All @@ -2572,8 +2548,8 @@ void Compiler::compSetProcessor()
}
}

// There are currently two sets of flags that control SSE3 through SSE4.2 support
// This is the general EnableSSE3_4 flag and the individual ISA flags. We need to
// There are currently two sets of flags that control SSE3 through SSE4.2 support:
// These are the general EnableSSE3_4 flag and the individual ISA flags. We need to
// check both for any given ISA.
if (JitConfig.EnableSSE3_4())
{
Expand Down Expand Up @@ -2606,6 +2582,34 @@ void Compiler::compSetProcessor()
}
}
}

// There are currently two sets of flags that control AVX, FMA, and AVX2 support:
// These are the general EnableAVX flag and the individual ISA flags. We need to
// check both for any given isa.
if (JitConfig.EnableAVX())
{
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX))
{
if (configEnableISA(InstructionSet_AVX))
{
opts.setSupportedISA(InstructionSet_AVX);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_FMA))
{
if (configEnableISA(InstructionSet_FMA))
{
opts.setSupportedISA(InstructionSet_FMA);
}
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX2))
{
if (configEnableISA(InstructionSet_AVX2))
{
opts.setSupportedISA(InstructionSet_AVX2);
}
}
}
}

if (!compIsForInlining())
Expand Down

0 comments on commit 8db778b

Please sign in to comment.