NetBSD-Bugs archive

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

Re: port-mips/57680: printf("%.1f") shows wrong results on R3000 mipseb



> Date: Tue, 7 Nov 2023 01:29:41 +0000 (UTC)
> From: RVP <rvp%SDF.ORG@localhost>
>  
> __flt_rounds() in src/lib/libc/arch/mips/gen/flt_rounds.c does:
>  
>          __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x));
>  
> while fegetround() -> __rfs() in src/sys/arch/mips/include/fenv.h only
> does:
>  
>          __asm __volatile("cfc1 %0,$31" : "=r" (__fpsr));
> [...]
> So, maybe a ".set push; ...; .set pop" is needed for older MIPS? Can you
> change __rfs() like that?

It's possible that change is correct, but I doubt it's the culprit.

In the objdump output that tsutsui@ quoted from __dtoa in the broken
libc, which I confirmed in my own build in the .o and .pico code
(although I haven't tested my build -- no hardware), there is no use
of the at register ($1, no overlap with any vN) and there is a nop in
the cfc1 load delay slot:

      50:	4442f800 	cfc1	v0,$31
      54:	00000000 	nop
      58:	30420003 	andi	v0,v0,0x3

So while maybe we ought to set noat and noreorder, and maybe we ought
to add a nop in the asm, that doesn't seem to be the source of the
problem.


Home | Main Index | Thread Index | Old Index