From 26d131ef29813c98d3dbd11b75120bf9c7ac7b5c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 16 May 2019 04:02:33 +0300 Subject: [PATCH] SPU LLVM: Fix Giga mode Forgot to adjust global chunk table computation. --- rpcs3/Emu/Cell/SPURecompiler.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index e52d9228c4..c08ba41b3d 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -7758,10 +7758,11 @@ public: // Try to load chunk address from the function table const auto fail = llvm::BasicBlock::Create(m_context, "", m_function); const auto done = llvm::BasicBlock::Create(m_context, "", m_function); - m_ir->CreateCondBr(m_ir->CreateICmpULT(addr.value, m_ir->getInt32(m_size)), done, fail, m_md_likely); + const auto ad32 = m_ir->CreateSub(addr.value, m_base_pc); + m_ir->CreateCondBr(m_ir->CreateICmpULT(ad32, m_ir->getInt32(m_size)), done, fail, m_md_likely); m_ir->SetInsertPoint(done); - const auto ad64 = m_ir->CreateZExt(addr.value, get_type()); + const auto ad64 = m_ir->CreateZExt(ad32, get_type()); const auto pptr = m_ir->CreateGEP(m_function_table, {m_ir->getInt64(0), m_ir->CreateLShr(ad64, 2, "", true)}); tail_chunk(m_ir->CreateLoad(pptr)); m_ir->SetInsertPoint(fail);