From 08a894abdea0ac5e7ea3de69df2b6edd80cc11ee Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 12 Jun 2019 22:17:25 -0700 Subject: [PATCH] interp: Handle NaN better in vfpu_dot. --- Core/MIPS/MIPSVFPUUtils.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index 1ad629d7c2..8de54a7834 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -635,6 +635,7 @@ float vfpu_dot(float a[4], float b[4]) { uint32_t exps[4]; int32_t mants[4]; uint32_t max_exp = 0; + uint32_t last_inf = 0; for (int i = 0; i < 4; i++) { exps[i] = get_uexp(intermed[i].i); @@ -643,6 +644,15 @@ float vfpu_dot(float a[4], float b[4]) { if (exps[i] > max_exp) { max_exp = exps[i]; } + if (exps[i] == 255) { + bool diff_sign = last_inf && get_sign(last_inf) != get_sign(intermed[i].i); + bool mant_nan = mants[i] != (0x00800000 << EXTRA_BITS); + if (diff_sign || mant_nan) { + intermed[0].i = 0x7F800001; + return intermed[0].f; + } + last_inf = intermed[i].i; + } } int32_t mant_sum = 0;