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

Re: (Hardware?) problem with denormal values on mipsel

On Wed, 2015-05-27 at 20:46 +0200, Ole Streicher wrote:
> Hi all,
> Am 27.05.2015 um 15:45 schrieb James Cowgill:
> > There's probably still a hardware bug in here somewhere, but before 3.16
> > the kernel was fixing it with the math emulator.
> Without understanding the discussion in detail, I'd like to bring a few
> points here back: the issue is not about SIGILL on *any* call of sqrt; it is
> just when it is called with a denormal number. Using f.e. 1.134e-32 f.e.
> worked for me.

Yes the Loongson machines do not implement the sqrt.s instruction for
denormals, but it works for normalized numbers.

> Also, the minimal "C" analogon
> #include <math.h>
> int main(void) {
>   float r = 1.1342362e-39;
>   r = sqrt(r);
>   exit(0);
> }

Your test case is wrong. If compiled without optimization, GCC call
'sqrt' from glibc instead of using the sqrt.s MIPS instruction. With
optimization GCC will remove the call altogether. This is different to
fortran because in fortran SQRT is a builtin intrinsic.

Try this instead (compile with -O2 -lm):

#include <math.h>
float x = 1.1342362e-39;
int main(void) {
  x = sqrt(x);
  return 0;


Attachment: signature.asc
Description: This is a digitally signed message part

Reply to: