[PATCH 09/10] fpu: Don't compile-time disable hardfloat for PPC targets

Peter Maydell posted 10 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 09/10] fpu: Don't compile-time disable hardfloat for PPC targets
Posted by Peter Maydell 1 month, 3 weeks ago
We happen to know that for the PPC target the FP status flags (and in
particular float_flag_inexact) will always be cleared before a
floating point operation, and so can_use_fpu() will always return
false.  So we speed things up a little by forcing QEMU_NO_HARDFLOAT
to true on that target.

We would like to build softfloat once for all targets; that means
removing target-specific ifdefs.  Remove the check for TARGET_PPC;
this won't change behaviour because can_use_fpu() will see that
float_flag_inexact is clear and take the softfloat path anyway.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 fpu/softfloat.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index b299cfaf860..b38eea8d879 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -220,11 +220,9 @@ GEN_INPUT_FLUSH3(float64_input_flush3, float64)
  * the use of hardfloat, since hardfloat relies on the inexact flag being
  * already set.
  */
-#if defined(TARGET_PPC) || defined(__FAST_MATH__)
 # if defined(__FAST_MATH__)
 #  warning disabling hardfloat due to -ffast-math: hardfloat requires an exact \
     IEEE implementation
-# endif
 # define QEMU_NO_HARDFLOAT 1
 # define QEMU_SOFTFLOAT_ATTR QEMU_FLATTEN
 #else
-- 
2.43.0
Re: [PATCH 09/10] fpu: Don't compile-time disable hardfloat for PPC targets
Posted by Richard Henderson 1 month, 3 weeks ago
On 2/17/25 04:50, Peter Maydell wrote:
> We happen to know that for the PPC target the FP status flags (and in
> particular float_flag_inexact) will always be cleared before a
> floating point operation, and so can_use_fpu() will always return
> false.  So we speed things up a little by forcing QEMU_NO_HARDFLOAT
> to true on that target.
> 
> We would like to build softfloat once for all targets; that means
> removing target-specific ifdefs.  Remove the check for TARGET_PPC;
> this won't change behaviour because can_use_fpu() will see that
> float_flag_inexact is clear and take the softfloat path anyway.
> 
> Signed-off-by: Peter Maydell<peter.maydell@linaro.org>
> ---
>   fpu/softfloat.c | 2 --
>   1 file changed, 2 deletions(-)

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

This makes ppc no different from the many other targets which clear out softfloat 
exception flags after every operation.


r~