From 68a5fc55d2c6ba3bf7645630eedb6a7f722ed540 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 22 May 2021 17:28:04 +0200 Subject: [PATCH] Interpreter: Fix fctiwx rounding The interpreter implementation of fctiwx was treating rounding mode 0 as "round to nearest, ties towards zero", which is not an actual IEEE-754 rounding mode. The IBM document mentioned in a comment at the top of the function, on the other hand, treats rounding mode 0 as "round to nearest, ties to even", which makes more sense. This fixes one of JMC's console-recorded F-Zero GX replays on JitArm64. (JitArm64 uses an interpreter fallback for fctiwx.) --- .../Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp index 4efb9b6166..04afcedfed 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp @@ -73,7 +73,8 @@ void ConvertToInteger(UGeckoInstruction inst, RoundingMode rounding_mode) const double t = b + 0.5; i = static_cast(t); - if (t - i < 0 || (t - i == 0 && b > 0)) + // Ties to even + if (t - i < 0 || (t - i == 0 && (i & 1))) { i--; }