From 78a7f4f426079be23ae9a20c2114e0e6cdd49079 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Thu, 24 May 2018 10:10:28 -0700 Subject: [PATCH] Updating the compiler to not enable FMA if the global AVX flag is disabled. Commit migrated from https://github.com/dotnet/coreclr/commit/8db778b54af3abd1b8b08b02515227a51b11e348 --- src/coreclr/src/jit/compiler.cpp | 66 +++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/coreclr/src/jit/compiler.cpp b/src/coreclr/src/jit/compiler.cpp index 31a2888..b1be7e7 100644 --- a/src/coreclr/src/jit/compiler.cpp +++ b/src/coreclr/src/jit/compiler.cpp @@ -2421,9 +2421,10 @@ 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; @@ -2431,8 +2432,6 @@ static bool configEnableISA(InstructionSet isa) 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: @@ -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; } @@ -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)) @@ -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)) @@ -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()) { @@ -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()) -- 2.7.4