qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] target/ppc: Bugfix FP when OE/UE are set


From: Richard Henderson
Subject: Re: [PATCH 2/2] target/ppc: Bugfix FP when OE/UE are set
Date: Fri, 5 Aug 2022 10:17:01 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 8/5/22 07:15, Lucas Mateus Castro(alqotel) wrote:
From: "Lucas Mateus Castro (alqotel)" <lucas.araujo@eldorado.org.br>

When an overflow exception occurs and OE is set the intermediate result
should be adjusted (by subtracting from the exponent) to avoid rounding
to inf. The same applies to an underflow exceptionion and UE (but adding
to the exponent). To do this set the fp_status.rebias_overflow when OE
is set and fp_status.rebias_underflow when UE is set as the FPU will
recalculate in case of a overflow/underflow if the according rebias* is
set.

Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>
---
  target/ppc/cpu.c        | 2 ++
  target/ppc/fpu_helper.c | 2 --
  2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/ppc/cpu.c b/target/ppc/cpu.c
index 401b6f9e63..0ebac04bc4 100644
--- a/target/ppc/cpu.c
+++ b/target/ppc/cpu.c
@@ -120,6 +120,8 @@ void ppc_store_fpscr(CPUPPCState *env, target_ulong val)
          val |= FP_FEX;
      }
      env->fpscr = val;
+    env->fp_status.rebias_overflow  = (FP_OE & env->fpscr) ? true : false;
+    env->fp_status.rebias_underflow = (FP_UE & env->fpscr) ? true : false;

No point in the ?: operator.

Otherwise,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~

      if (tcg_enabled()) {
          fpscr_set_rounding_mode(env);
      }
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index 134804628b..c17575de5d 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -344,7 +344,6 @@ static inline int float_overflow_excp(CPUPPCState *env)
bool overflow_enabled = !!(env->fpscr & FP_OE);
      if (overflow_enabled) {
-        /* XXX: should adjust the result */
          /* Update the floating-point enabled exception summary */
          env->fpscr |= FP_FEX;
          /* We must update the target FPR before raising the exception */
@@ -363,7 +362,6 @@ static inline void float_underflow_excp(CPUPPCState *env)
      /* Update the floating-point exception summary */
      env->fpscr |= FP_FX;
      if (env->fpscr & FP_UE) {
-        /* XXX: should adjust the result */
          /* Update the floating-point enabled exception summary */
          env->fpscr |= FP_FEX;
          /* We must update the target FPR before raising the exception */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]