On Wed, 4 May 2016, Aleksandar Markovic wrote:

> > > @@ -8919,7 +8920,11 @@ static void gen_farith (DisasContext *ctx, enum 
> > > fopcode op1,
> > >              TCGv_i64 fp64 = tcg_temp_new_i64();
> > >
> > >              gen_load_fpr32(ctx, fp32, fs);
> > > -            gen_helper_float_roundl_s(fp64, cpu_env, fp32);
> > > +            if ((ctx->insn_flags & ISA_MIPS32R6) && (ctx->nan2008)) {
> 
> > Why testing the version of the architecture? This will generate wrong
> > helper for P5600 which is R5 and IEEE 754-2008 compliant.
> 
> The code reflects the documentation.
> 
> I just want to bring to your attention following two versions of the 
> paragraph detailing return value of ROUND.L.S for some special cases - one 
> version from R6 documention, and the other from R5 documentation:
> 
> R6: ("MIPS® Architecture For Programmers Volume II-A: The MIPS64® Instruction 
> Set Reference Manual", Revision 6.04, page 393)
> 
> "When the source value is Infinity, NaN, or rounds to an integer outside the 
> range -2 63 to 2 63 -1, the result cannot be
> represented correctly and an IEEE Invalid Operation condition exists. The 
> Invalid Operation flag is set in the FCSR.
> If the Invalid Operation Enable bit is set in the FCSR, no result is written 
> to fd and an Invalid Operation exception is
> taken immediately. Otherwise, a default result is written to fd. On cores 
> with FCSR[NAN2008]=0, the default result is
> 2^63–1. On cores with FCSR[NAN2008]=1, the default result is:
>   • 0 when the input value is NaN
>   • 2^63 –1 when the input value is +infinity or rounds to a number larger 
> than 2^63 –1
>   • -2^63 –1 when the input value is –infinity or rounds to a number smaller 
> than -2^63 –1"

 This is clearly wrong given that FCSR[NAN2008] is hardwired to 1 in R6; 
see Table 6.8 in MIPS64 vol. I rev. 6.01.  Please note that individual 
instruction descriptions should not be used as a (primary) reference, 
especially in the case of documentation discrepancies -- refer to Table 
6.3 in vol. I for architectural definitions.

> R5: ("MIPS® Architecture For Programmers Volume II-A: The MIPS64® Instruction 
> Set Reference Manual", Revision 5.04, page 314)
> 
> "When the source value is Infinity, NaN, or rounds to an integer outside the 
> range -2 63 to 2 63 -1, the result cannot be
> represented correctly and an IEEE Invalid Operation condition exists. In this 
> case the Invalid Operation flag is set in
> the FCSR. If the Invalid Operation Enable bit is set in the FCSR, no result 
> is written to fd and an Invalid Operation
> exception is taken immediately. Otherwise, the default result, 2 63 – 1, is 
> written to fd."

 This is likewise wrong, and refer to Table 5.7 and 5.3 respectively in 
MIPS64 vol. I rev. 5.04.

 In any case FCSR[NAN2008] is the only condition to be referred.

  Maciej

Reply via email to