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



The following reply was made to PR port-mips/57680; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: port-mips/57680: printf("%.1f") shows wrong results on R3000
 mipseb
Date: Tue, 7 Nov 2023 01:29:41 +0000 (UTC)

 On Mon, 6 Nov 2023, Izumi Tsutsui wrote:
 
 > >  Don't get this either. With both -DHonor_FLT_ROUNDS and -DTrust_FLT_ROUNDS
 > >  defined `int Rounding' should get set to `1'--exactly the same as with
 > >  -DHonor_FLT_ROUNDS alone.
 >
 > It looks the problem is not a (expected) value of "Rounding",
 > but unexpected optimization around inlined fegetround().
 > (but not sure)
 >
 
 Hmm. I think I see what you mean.
 
 __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));
 
 According to "9.27.11 Directives to save and restore options" in the GAS
 manual (https://sourceware.org/binutils/docs-2.41/as.html#MIPS_002dDependent)
 
  	The directives .set push and .set pop may be used to save
  	and restore the current settings for all the options which
  	are controlled by .set. The .set push directive saves the
  	current settings on a stack. The .set pop directive pops
  	the stack and restores the settings.
 
  	These directives can be useful inside an macro which must
  	change an option such as the ISA level or instruction
  	reordering but does not want to change the state of the
  	code which invoked the macro.
 
 So, maybe a ".set push; ...; .set pop" is needed for older MIPS? Can you
 change __rfs() like that?
 
 -RVP
 


Home | Main Index | Thread Index | Old Index