summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMerry <MerryMage@users.noreply.github.com>2017-05-22 01:50:52 +0200
committerGitHub <noreply@github.com>2017-05-22 01:50:52 +0200
commit188d63fdb62fbbcfa287e470cefa6c27efa2977d (patch)
tree694246e4d8bfcfa175953cbc70b018fb3f8d6ea3
parentMerge pull request #2719 from lioncash/catch (diff)
parentDyncom/VFP: Perform flush-to-zero on the second operand of vsub before sending it to vadd. (diff)
downloadyuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar.gz
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar.bz2
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar.lz
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar.xz
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.tar.zst
yuzu-188d63fdb62fbbcfa287e470cefa6c27efa2977d.zip
-rw-r--r--src/core/arm/skyeye_common/vfp/vfpsingle.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp
index ae5b325f0..6b4cb8efa 100644
--- a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp
+++ b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp
@@ -1049,12 +1049,22 @@ static u32 vfp_single_fadd(ARMul_State* state, int sd, int sn, s32 m, u32 fpscr)
static u32 vfp_single_fsub(ARMul_State* state, int sd, int sn, s32 m, u32 fpscr) {
LOG_TRACE(Core_ARM11, "s%u = %08x", sn, sd);
/*
- * Subtraction is addition with one sign inverted.
+ * Subtraction is addition with one sign inverted. Unpack the second operand to perform FTZ if
+ * necessary, we can't let fadd do this because a denormal in m might get flushed to +0 in FTZ
+ * mode, and the resulting sign of 0 OP +0 differs between fadd and fsub. We do not need to do
+ * this for n because +0 OP 0 is always +0 for both fadd and fsub.
*/
+ struct vfp_single vsm;
+ u32 exceptions = vfp_single_unpack(&vsm, m, fpscr);
+ if (exceptions & FPSCR_IDC) {
+ // The value was flushed to zero, re-pack it.
+ m = vfp_single_pack(&vsm);
+ }
+
if (m != 0x7FC00000) // Only negate if m isn't NaN.
m = vfp_single_packed_negate(m);
- return vfp_single_fadd(state, sd, sn, m, fpscr);
+ return vfp_single_fadd(state, sd, sn, m, fpscr) | exceptions;
}
/*