From d41287c3202ef6dc352e0e2ee1e7c7e280f12fc4 Mon Sep 17 00:00:00 2001 From: joevt Date: Wed, 27 Nov 2024 04:31:36 -0800 Subject: [PATCH] ppcfpopcodes: fneg fix. fneg inverts the sign bit regardless of nan status. --- cpu/ppc/ppcfpopcodes.cpp | 15 ++++----------- cpu/ppc/ppcmacros.h | 5 ++++- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cpu/ppc/ppcfpopcodes.cpp b/cpu/ppc/ppcfpopcodes.cpp index 5b15677..172a93c 100644 --- a/cpu/ppc/ppcfpopcodes.cpp +++ b/cpu/ppc/ppcfpopcodes.cpp @@ -816,18 +816,11 @@ template void dppc_interpreter::ppc_fneg() { ppc_grab_regsfpdb(ppc_cur_instruction); - double ppc_dblresult64_d = -(GET_FPR(reg_b)); + uint64_t ppc_result64_d = FPR_INT(reg_b) ^ 0x8000000000000000U; - if (std::isnan(GET_FPR(reg_b))) { - ppc_dblresult64_d = std::numeric_limits::quiet_NaN(); - } - - if (snan_single_check(reg_b)) { - uint64_t qnan = 0x7FFC000000000000; - ppc_store_fpresult_int(reg_d, qnan); - } else { - ppc_store_fpresult_flt(reg_d, ppc_dblresult64_d); - } + ppc_store_fpresult_int(reg_d, ppc_result64_d); + + snan_single_check(reg_d); if (rec) ppc_update_cr1(); diff --git a/cpu/ppc/ppcmacros.h b/cpu/ppc/ppcmacros.h index 4417926..25c25c2 100644 --- a/cpu/ppc/ppcmacros.h +++ b/cpu/ppc/ppcmacros.h @@ -150,9 +150,12 @@ along with this program. If not, see . int reg_d = (opcode >> 21) & 31; \ int reg_b = (opcode >> 11) & 31; -#define GET_FPR(reg) \ +#define GET_FPR(reg) \ ppc_state.fpr[(reg)].dbl64_r +#define FPR_INT(reg)\ + ppc_state.fpr[reg].int64_r + #define ppc_grab_regsfpdiab(opcode) \ int reg_d = (opcode >> 21) & 31; \ int reg_a = (opcode >> 16) & 31; \