qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 04/10] target/tricore: Implement FTOU insn


From: Bastian Koppelmann
Subject: Re: [PATCH 04/10] target/tricore: Implement FTOU insn
Date: Sun, 27 Aug 2023 20:59:39 +0200

On Sun, Aug 27, 2023 at 11:32:03AM -0700, Richard Henderson wrote:
> On 8/27/23 09:36, Bastian Koppelmann wrote:
> > On Sun, Aug 27, 2023 at 07:49:52AM -0700, Richard Henderson wrote:
> > > On 8/27/23 04:07, Bastian Koppelmann wrote:
> > > > On Sat, Aug 26, 2023 at 09:50:51PM -0700, Richard Henderson wrote:
> > > > > On 8/26/23 09:02, Bastian Koppelmann wrote:
> > > > > > +uint32_t helper_ftou(CPUTriCoreState *env, uint32_t arg)
> > > > > > +{
> > > > > > +    float32 f_arg = make_float32(arg);
> > > > > > +    uint32_t result;
> > > > > > +    int32_t flags = 0;
> > > > > > +
> > > > > > +    if (float32_is_any_nan(f_arg)) {
> > > > > > +        result = 0;
> > > > > > +        flags |= float_flag_invalid;
> > > > > > +    } else if (float32_lt_quiet(f_arg, 0, &env->fp_status)) {
> > > > > > +        result = 0;
> > > > > > +        flags = float_flag_invalid;
> > > > > > +    } else {
> > > > > > +        result = float32_to_uint32(f_arg, &env->fp_status);
> > > > > > +        flags = f_get_excp_flags(env);
> > > > > > +    }
> > > > > 
> > > > > You should allow softfloat to diagnose the special cases, and 
> > > > > negative -> 0
> > > > > is standard behaviour.  Therefore:
> > > > 
> > > > You're right. However, there is one special case, negative -> 0 ought 
> > > > to raise
> > > > float_flags_invalid.
> > > 
> > > https://gitlab.com/qemu-project/qemu/-/blob/master/fpu/softfloat-parts.c.inc?ref_type=heads#L1162
> > 
> > Lets say the exponent is negative and the sign is negative, then we raise
> > float_flag_inexact and we never reach the code you mentioned here. However,
> > TriCore HW raises float_flag_invalid as well in that case. This is what I'm
> > catching with float32_lt_quiet() in the same manner as ftouz.
> 
> Hmph.  Buggy hardware.  You'd better document this special case,
> that less-than-zero is detected before rounding.

Will do. I'll do the same for ftouz.

> 
> I presume -0.0 does not raise invalid, that the bug does not extend that far?

Yes, -0.0 does not raise invalid.

Cheers,
Bastian



reply via email to

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