From 235d12aa6b761b53380ce7e92cc3c518042366c1 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 2 Jul 2020 18:10:43 +0300 Subject: [PATCH] SPU MFC: Never clear tag status in WrTagUpdate --- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 1 - rpcs3/Emu/Cell/SPURecompiler.cpp | 14 ++++++++++---- rpcs3/Emu/Cell/SPUThread.cpp | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index b17feddf1f..6b1fedd050 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -2515,7 +2515,6 @@ void spu_recompiler::WRCH(spu_opcode_t op) c->bind(zero); c->mov(SPU_OFF_32(ch_tag_upd), qw0->r32()); - c->mov(SPU_OFF_64(ch_tag_stat), 0); c->jmp(ret); }); diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 0d5bd8f6df..9242edbbdc 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -5702,9 +5702,9 @@ public: } case MFC_WrTagUpdate: { - if (auto ci = llvm::dyn_cast(val.value)) + if (auto ci = llvm::dyn_cast(val.value); true) { - const u64 upd = ci->getZExtValue(); + const u64 upd = ci ? ci->getZExtValue() : UINT64_MAX; const auto tag_mask = m_ir->CreateLoad(spu_ptr(&spu_thread::ch_tag_mask)); const auto mfc_fence = m_ir->CreateLoad(spu_ptr(&spu_thread::mfc_fence)); @@ -5722,8 +5722,14 @@ public: else if (upd <= MFC_TAG_UPDATE_ALL) { const auto cond = upd == MFC_TAG_UPDATE_ANY ? m_ir->CreateICmpNE(completed, m_ir->getInt32(0)) : m_ir->CreateICmpEQ(completed, tag_mask); - m_ir->CreateStore(m_ir->CreateSelect(cond, m_ir->getInt32(MFC_TAG_UPDATE_IMMEDIATE), m_ir->getInt32(static_cast(upd))), upd_ptr); - m_ir->CreateStore(m_ir->CreateSelect(cond, stat_val, m_ir->getInt64(0)), stat_ptr); + m_ir->CreateStore(m_ir->CreateSelect(cond, m_ir->getInt32(MFC_TAG_UPDATE_IMMEDIATE), val.value), upd_ptr); + const auto next = llvm::BasicBlock::Create(m_context, "", m_function); + const auto update = llvm::BasicBlock::Create(m_context, "", m_function); + m_ir->CreateCondBr(cond, update, next); + m_ir->SetInsertPoint(update); + m_ir->CreateStore(stat_val, stat_ptr); + m_ir->CreateBr(next); + m_ir->SetInsertPoint(next); return; } } diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 781bfec486..1d35231054 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -2817,7 +2817,6 @@ bool spu_thread::set_ch_value(u32 ch, u32 value) else { ch_tag_upd = value; - ch_tag_stat.set_value(0, false); } return true;