From 7573d7289b603deb8f8f9b6bf008ebd2ec13c98f Mon Sep 17 00:00:00 2001 From: Malcolm Jestadt Date: Fri, 5 Nov 2021 17:05:04 -0400 Subject: [PATCH] SPU LLVM: Hook up 128 bit spu verification - Also fix FMA enablement for sapphirerapids --- rpcs3/Emu/CPU/CPUTranslator.cpp | 20 ++++++++++++++------ rpcs3/Emu/CPU/CPUTranslator.h | 3 +++ rpcs3/Emu/Cell/SPURecompiler.cpp | 8 ++++---- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/rpcs3/Emu/CPU/CPUTranslator.cpp b/rpcs3/Emu/CPU/CPUTranslator.cpp index 7b21055a3b..6af0cdee42 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.cpp +++ b/rpcs3/Emu/CPU/CPUTranslator.cpp @@ -85,6 +85,14 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin m_use_ssse3 = false; } + // Test AVX feature (TODO) + if (cpu == "sandybridge" || + cpu == "ivybridge" || + cpu == "bdver1") + { + m_use_avx = true; + } + // Test FMA feature (TODO) if (cpu == "haswell" || cpu == "broadwell" || @@ -96,19 +104,16 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin cpu.startswith("znver")) { m_use_fma = true; + m_use_avx = 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" || - cpu == "rocketlake") + cpu == "cooperlake") { + m_use_avx = true; m_use_fma = true; m_use_avx512 = true; } @@ -129,6 +134,9 @@ void cpu_translator::initialize(llvm::LLVMContext& context, llvm::ExecutionEngin cpu == "rocketlake" || cpu == "sapphirerapids") { + m_use_avx = true; + m_use_fma = true; + m_use_avx512 = true; m_use_avx512_icl = true; m_use_vnni = true; } diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index aa49d2a21c..fe17dba309 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -2886,6 +2886,9 @@ protected: // Allow FMA bool m_use_fma = false; + // Allow AVX + bool m_use_avx = false; + // Allow skylake-x tier AVX-512 bool m_use_avx512 = false; diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 4735d4384e..dda1870511 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -4485,13 +4485,13 @@ public: elements = 16; dwords = 8; } - else if (true) + else if (m_use_avx) { stride = 32; elements = 8; dwords = 4; } - else // TODO: Use this path when the cpu doesn't support AVX + else { stride = 16; elements = 4; @@ -4539,7 +4539,7 @@ public: { vls = m_ir->CreateAlignedLoad(_ptr(data_addr, j - starta), llvm::MaybeAlign{4}); } - else if (true) + else if (m_use_avx) { vls = m_ir->CreateAlignedLoad(_ptr(data_addr, j - starta), llvm::MaybeAlign{4}); } @@ -4573,7 +4573,7 @@ public: { acc = m_ir->CreateBitCast(acc, get_type()); } - else if (true) + else if (m_use_avx) { acc = m_ir->CreateBitCast(acc, get_type()); }