CPUTranslator: detect FMA feature

This commit is contained in:
Nekotekina 2019-12-20 21:11:07 +03:00
parent 4a5c8c392c
commit 068450d4fe
3 changed files with 35 additions and 5 deletions

View file

@ -958,10 +958,12 @@ std::string jit_compiler::cpu(const std::string& _cpu)
m_cpu == "skylake" || m_cpu == "skylake" ||
m_cpu == "skylake-avx512" || m_cpu == "skylake-avx512" ||
m_cpu == "cascadelake" || m_cpu == "cascadelake" ||
m_cpu == "cooperlake" ||
m_cpu == "cannonlake" || m_cpu == "cannonlake" ||
m_cpu == "icelake" || m_cpu == "icelake" ||
m_cpu == "icelake-client" || m_cpu == "icelake-client" ||
m_cpu == "icelake-server") m_cpu == "icelake-server" ||
m_cpu == "tigerlake")
{ {
// Downgrade if AVX is not supported by some chips // Downgrade if AVX is not supported by some chips
if (!utils::has_avx()) if (!utils::has_avx())
@ -972,10 +974,12 @@ std::string jit_compiler::cpu(const std::string& _cpu)
if (m_cpu == "skylake-avx512" || if (m_cpu == "skylake-avx512" ||
m_cpu == "cascadelake" || m_cpu == "cascadelake" ||
m_cpu == "cooperlake" ||
m_cpu == "cannonlake" || m_cpu == "cannonlake" ||
m_cpu == "icelake" || m_cpu == "icelake" ||
m_cpu == "icelake-client" || m_cpu == "icelake-client" ||
m_cpu == "icelake-server") m_cpu == "icelake-server" ||
m_cpu == "tigerlake")
{ {
// Downgrade if AVX-512 is disabled or not supported // Downgrade if AVX-512 is disabled or not supported
if (!utils::has_512()) if (!utils::has_512())

View file

@ -18,8 +18,6 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin
const auto cpu = m_engine->getTargetMachine()->getTargetCPU(); const auto cpu = m_engine->getTargetMachine()->getTargetCPU();
m_use_ssse3 = true;
// Test SSSE3 feature (TODO) // Test SSSE3 feature (TODO)
if (cpu == "generic" || if (cpu == "generic" ||
cpu == "k8" || cpu == "k8" ||
@ -34,6 +32,31 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin
{ {
m_use_ssse3 = false; m_use_ssse3 = false;
} }
// Test FMA feature (TODO)
if (cpu == "haswell" ||
cpu == "broadwell" ||
cpu == "skylake" ||
cpu == "bdver2" ||
cpu == "bdver3" ||
cpu == "bdver4" ||
cpu.substr(0, 5) == "znver")
{
m_use_fma = true;
}
// Test AVX-512 feature (TODO)
if (cpu == "skylake-avx512" ||
cpu == "cascadelake" ||
cpu == "cannonlake" ||
cpu == "cooperlake" ||
cpu == "icelake" ||
cpu == "icelake-client" ||
cpu == "icelake-server" ||
cpu == "tigerlake")
{
m_use_fma = true;
}
} }
llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type) llvm::Value* cpu_translator::bitcast(llvm::Value* val, llvm::Type* type)

View file

@ -2404,7 +2404,10 @@ protected:
bool m_is_be; bool m_is_be;
// Allow PSHUFB intrinsic // Allow PSHUFB intrinsic
bool m_use_ssse3; bool m_use_ssse3 = true;
// Allow FMA
bool m_use_fma = false;
// IR builder // IR builder
llvm::IRBuilder<>* m_ir; llvm::IRBuilder<>* m_ir;