diff mbox series

[1/1] target/ppc: Fix do_float_check_status vs inexact

Message ID 20190826165434.18403-2-richard.henderson@linaro.org
State Superseded
Headers show
Series Fix LP#1841442 for powerpc | expand

Commit Message

Richard Henderson Aug. 26, 2019, 4:54 p.m. UTC
The underflow and inexact exceptions are not mutually exclusive.
Check for both of them.  Tidy the reset of FPSCR[FI].

Fixes: https://bugs.launchpad.net/bugs/1841442
Reported-by: Paul Clarke <pc@us.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 target/ppc/fpu_helper.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

-- 
2.17.1

Comments

Paul Clarke Aug. 26, 2019, 8:43 p.m. UTC | #1
On 8/26/19 11:54 AM, Richard Henderson wrote:
> The underflow and inexact exceptions are not mutually exclusive.

> Check for both of them.  Tidy the reset of FPSCR[FI].

> 

> Fixes: https://bugs.launchpad.net/bugs/1841442

> Reported-by: Paul Clarke <pc@us.ibm.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Tested-by: Paul Clarke <pc@us.ibm.com>


Thanks, Richard!

There seems to be a similar problem with underflow.  I'll narrow down a test case, and I guess I'll just open a new bug report.

PC
> ---

>  target/ppc/fpu_helper.c | 10 +++-------

>  1 file changed, 3 insertions(+), 7 deletions(-)

> 

> diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c

> index 07bc9051b0..2e023c5204 100644

> --- a/target/ppc/fpu_helper.c

> +++ b/target/ppc/fpu_helper.c

> @@ -630,19 +630,15 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)

>  {

>      CPUState *cs = env_cpu(env);

>      int status = get_float_exception_flags(&env->fp_status);

> -    bool inexact_happened = false;

>  

>      if (status & float_flag_overflow) {

>          float_overflow_excp(env);

>      } else if (status & float_flag_underflow) {

>          float_underflow_excp(env);

> -    } else if (status & float_flag_inexact) {

> -        float_inexact_excp(env);

> -        inexact_happened = true;

>      }

> -

> -    /* if the inexact flag was not set */

> -    if (inexact_happened == false) {

> +    if (status & float_flag_inexact) {

> +        float_inexact_excp(env);

> +    } else {

>          env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */

>      }

>  

>
David Gibson Aug. 27, 2019, 3:42 a.m. UTC | #2
On Mon, Aug 26, 2019 at 09:54:34AM -0700, Richard Henderson wrote:
> The underflow and inexact exceptions are not mutually exclusive.

> Check for both of them.  Tidy the reset of FPSCR[FI].

> 

> Fixes: https://bugs.launchpad.net/bugs/1841442

> Reported-by: Paul Clarke <pc@us.ibm.com>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Applied to ppc-for-4.2, thanks.

> ---

>  target/ppc/fpu_helper.c | 10 +++-------

>  1 file changed, 3 insertions(+), 7 deletions(-)

> 

> diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c

> index 07bc9051b0..2e023c5204 100644

> --- a/target/ppc/fpu_helper.c

> +++ b/target/ppc/fpu_helper.c

> @@ -630,19 +630,15 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)

>  {

>      CPUState *cs = env_cpu(env);

>      int status = get_float_exception_flags(&env->fp_status);

> -    bool inexact_happened = false;

>  

>      if (status & float_flag_overflow) {

>          float_overflow_excp(env);

>      } else if (status & float_flag_underflow) {

>          float_underflow_excp(env);

> -    } else if (status & float_flag_inexact) {

> -        float_inexact_excp(env);

> -        inexact_happened = true;

>      }

> -

> -    /* if the inexact flag was not set */

> -    if (inexact_happened == false) {

> +    if (status & float_flag_inexact) {

> +        float_inexact_excp(env);

> +    } else {

>          env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */

>      }

>  


-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
diff mbox series

Patch

diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 07bc9051b0..2e023c5204 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -630,19 +630,15 @@  static void do_float_check_status(CPUPPCState *env, uintptr_t raddr)
 {
     CPUState *cs = env_cpu(env);
     int status = get_float_exception_flags(&env->fp_status);
-    bool inexact_happened = false;
 
     if (status & float_flag_overflow) {
         float_overflow_excp(env);
     } else if (status & float_flag_underflow) {
         float_underflow_excp(env);
-    } else if (status & float_flag_inexact) {
-        float_inexact_excp(env);
-        inexact_happened = true;
     }
-
-    /* if the inexact flag was not set */
-    if (inexact_happened == false) {
+    if (status & float_flag_inexact) {
+        float_inexact_excp(env);
+    } else {
         env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */
     }