diff --git a/src/core/cpu_core.cpp b/src/core/cpu_core.cpp index 2505ea0fb..c67e7191a 100644 --- a/src/core/cpu_core.cpp +++ b/src/core/cpu_core.cpp @@ -939,7 +939,7 @@ restart_instruction: WriteReg(inst.i.rt, value); if constexpr (pgxp_mode >= PGXPMode::CPU) - PGXP::CPU_LUI(inst.bits, value); + PGXP::CPU_LUI(inst.bits); } break; diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp index e423d1a65..12a2eed94 100644 --- a/src/core/cpu_recompiler_code_generator.cpp +++ b/src/core/cpu_recompiler_code_generator.cpp @@ -2274,16 +2274,11 @@ bool CodeGenerator::Compile_lui(const CodeBlockInstruction& cbi) { InstructionPrologue(cbi, 1); + if (g_settings.UsingPGXPCPUMode()) + EmitFunctionCall(nullptr, &PGXP::CPU_LUI, Value::FromConstantU32(cbi.instruction.bits)); + // rt <- (imm << 16) const u32 value = cbi.instruction.i.imm_zext32() << 16; - - if (g_settings.UsingPGXPCPUMode()) - { - // TODO: rtVal can be skipped here, and probably worthwhile given this is a common instruction. - EmitFunctionCall(nullptr, &PGXP::CPU_LUI, Value::FromConstantU32(cbi.instruction.bits), - Value::FromConstantU32(value)); - } - m_register_cache.WriteGuestRegister(cbi.instruction.i.rt, Value::FromConstantU32(value)); SpeculativeWriteReg(cbi.instruction.i.rt, value); diff --git a/src/core/pgxp.cpp b/src/core/pgxp.cpp index 66e2d8188..8a2ca79f8 100644 --- a/src/core/pgxp.cpp +++ b/src/core/pgxp.cpp @@ -1045,13 +1045,13 @@ void CPU_SLTIU(u32 instr, u32 rtVal, u32 rsVal) //////////////////////////////////// // Load Upper //////////////////////////////////// -void CPU_LUI(u32 instr, u32 rtVal) +void CPU_LUI(u32 instr) { // Rt = Imm << 16 CPU_reg[rt(instr)] = PGXP_value_zero; CPU_reg[rt(instr)].y = (float)(s16)imm(instr); CPU_reg[rt(instr)].hFlags = VALID_HALF; - CPU_reg[rt(instr)].value = rtVal; + CPU_reg[rt(instr)].value = static_cast(imm(instr)) << 16; CPU_reg[rt(instr)].flags = VALID_01; } diff --git a/src/core/pgxp.h b/src/core/pgxp.h index ec3851427..04399bfb6 100644 --- a/src/core/pgxp.h +++ b/src/core/pgxp.h @@ -63,7 +63,7 @@ void CPU_SLTI(u32 instr, u32 rtVal, u32 rsVal); void CPU_SLTIU(u32 instr, u32 rtVal, u32 rsVal); // Load Upper -void CPU_LUI(u32 instr, u32 rtVal); +void CPU_LUI(u32 instr); // Register Arithmetic void CPU_ADD(u32 instr, u32 rdVal, u32 rsVal, u32 rtVal);