From b1a29371c9955a79bb9353043532316516512334 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 8 May 2017 14:34:16 -0500 Subject: Dyncom/VFP: Convert denormal outputs into 0 when the FTZ flag is enabled. Inputs are still not flushed to 0 if they are denormals. --- src/core/arm/skyeye_common/vfp/vfpdouble.cpp | 15 +++++++++++++++ src/core/arm/skyeye_common/vfp/vfpsingle.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'src/core/arm') diff --git a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp index 2886f351f..49c192dd3 100644 --- a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp @@ -135,6 +135,21 @@ u32 vfp_double_normaliseround(ARMul_State* state, int dd, struct vfp_double* vd, #endif if (!(significand & ((1ULL << (VFP_DOUBLE_LOW_BITS + 1)) - 1))) underflow = 0; + + int type = vfp_double_type(vd); + + if ((type & VFP_DENORMAL) && (fpscr & FPSCR_FLUSH_TO_ZERO)) { + // Flush denormal to positive 0 + exponent = 0; + significand = 0; + + vd->sign = 0; + vd->exponent = exponent; + vd->significand = significand; + + underflow = 0; + exceptions |= FPSCR_UFC; + } } /* diff --git a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp index 1590d89a4..85dd0c6a0 100644 --- a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp @@ -138,6 +138,21 @@ u32 vfp_single_normaliseround(ARMul_State* state, int sd, struct vfp_single* vs, #endif if (!(significand & ((1 << (VFP_SINGLE_LOW_BITS + 1)) - 1))) underflow = 0; + + int type = vfp_single_type(vs); + + if ((type & VFP_DENORMAL) && (fpscr & FPSCR_FLUSH_TO_ZERO)) { + // Flush denormal to positive 0 + exponent = 0; + significand = 0; + + vs->sign = 0; + vs->exponent = exponent; + vs->significand = significand; + + underflow = 0; + exceptions |= FPSCR_UFC; + } } /* -- cgit v1.2.3 From 5b46a89230790d01e21ffaebf3731f68b7bbb4dc Mon Sep 17 00:00:00 2001 From: Subv Date: Sun, 21 May 2017 18:56:09 -0500 Subject: fixup! Dyncom/VFP: Convert denormal outputs into 0 when the FTZ flag is enabled. --- src/core/arm/skyeye_common/vfp/vfpdouble.cpp | 2 -- src/core/arm/skyeye_common/vfp/vfpsingle.cpp | 2 -- 2 files changed, 4 deletions(-) (limited to 'src/core/arm') diff --git a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp index 49c192dd3..e51927de5 100644 --- a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp @@ -140,11 +140,9 @@ u32 vfp_double_normaliseround(ARMul_State* state, int dd, struct vfp_double* vd, if ((type & VFP_DENORMAL) && (fpscr & FPSCR_FLUSH_TO_ZERO)) { // Flush denormal to positive 0 - exponent = 0; significand = 0; vd->sign = 0; - vd->exponent = exponent; vd->significand = significand; underflow = 0; diff --git a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp index 85dd0c6a0..99ab80145 100644 --- a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp @@ -143,11 +143,9 @@ u32 vfp_single_normaliseround(ARMul_State* state, int sd, struct vfp_single* vs, if ((type & VFP_DENORMAL) && (fpscr & FPSCR_FLUSH_TO_ZERO)) { // Flush denormal to positive 0 - exponent = 0; significand = 0; vs->sign = 0; - vs->exponent = exponent; vs->significand = significand; underflow = 0; -- cgit v1.2.3