From 63ad856afa353767415f96cfacaf8a134272031f Mon Sep 17 00:00:00 2001 From: izcarti <191240052+izcarti@users.noreply.github.com> Date: Fri, 9 Oct 2026 19:41:09 +0100 Subject: [PATCH] PPU LLVM: Estimate a whole vector per call --- rpcs3/Emu/Cell/PPUThread.cpp | 17 +++++++++++++---- rpcs3/Emu/Cell/PPUTranslator.cpp | 14 +++++--------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 2b0adb2470..551a8da0b0 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -4888,6 +4888,15 @@ extern void ppu_initialize() } } +template +static void ppu_vec_estimate(v128& v, u32 nj) +{ + for (u32 i = 0; i < 4; i++) + { + v._u32[i] = Estimate(v._u32[i], nj != 0); + } +} + bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_size) { ppu_log.notice("Entering ppu_initialize(const ppu_module&..)"); @@ -4968,10 +4977,10 @@ bool ppu_initialize(const ppu_module& info, bool check_only, u64 file_s { "__escape", reinterpret_cast(+ppu_escape) }, { "__read_maybe_mmio32", reinterpret_cast(+ppu_read_mmio_aware_u32) }, { "__write_maybe_mmio32", reinterpret_cast(+ppu_write_mmio_aware_u32) }, - { "__vrefp", reinterpret_cast(+[](u32 x, u32 nj) { return ppu_vrefp(x, nj != 0); }) }, - { "__vrsqrtefp", reinterpret_cast(+[](u32 x, u32 nj) { return ppu_vrsqrtefp(x, nj != 0); }) }, - { "__vexptefp", reinterpret_cast(+[](u32 x, u32 nj) { return ppu_vexptefp(x, nj != 0); }) }, - { "__vlogefp", reinterpret_cast(+[](u32 x, u32 nj) { return ppu_vlogefp(x, nj != 0); }) }, + { "__vrefp", reinterpret_cast(&ppu_vec_estimate) }, + { "__vrsqrtefp", reinterpret_cast(&ppu_vec_estimate) }, + { "__vexptefp", reinterpret_cast(&ppu_vec_estimate) }, + { "__vlogefp", reinterpret_cast(&ppu_vec_estimate) }, }; for (u64 index = 0; index < 1024; index++) diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index b5fdb23711..386ab31da3 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -491,16 +491,12 @@ Value* PPUTranslator::VecHandleResult(Value* val, bool flush_denormals_manually) Value* PPUTranslator::VecEstimate(StringRef name, u32 vr) { - const auto b = GetVr(vr, VrType::vi32); - const auto nj = ZExt(RegLoad(m_nj), GetType()); - Value* result = GetUndef(); + auto& entry = m_function->getEntryBlock(); + const auto data = IRBuilder<>(&entry, entry.getFirstInsertionPt()).CreateAlloca(GetType()); - for (u32 i = 0; i < 4; i++) - { - result = m_ir->CreateInsertElement(result, Call(GetType(), m_pure_attr, name, m_ir->CreateExtractElement(b, i), nj), i); - } - - return result; + m_ir->CreateStore(GetVr(vr, VrType::vi32), data); + Call(GetType(), name, data, ZExt(RegLoad(m_nj), GetType())); + return m_ir->CreateLoad(GetType(), data); } Value* PPUTranslator::GetAddr(u64 _add)