On Fri, Apr 08, 2011 at 09:52:39AM +0200, [email protected] wrote:
> -[ Fri, Apr 08, 2011 at 09:37:52AM +0200, Lluís Batlle i Rossell ]----
> > Rixed, if I understand well, you used a *signaling NaN* value in the
> > operation,
> > that should result in an invalid operation.
Further investigations showed that there is some place where 'signaling nan' and
'quiet nan' are MIXED.
For example, the C++ numeric_limits<double> in mips encodes the quiet nan this
way: 0x7ff7ffffffffffff
and the signaling nan this way: 0x7fffffffffffffff
The operations with that quiet nan end in SIGILL, while the operations with
that signaling nan go just fine. It has nothing to do with even or odd
register numbers
The glibc bits/nan.h reads:
/* IEEE Not A Number (QNaN). Note that MIPS has the QNaN and SNaN patterns
reversed compared to most other architectures. The IEEE spec left
the definition of this open to implementations, and for MIPS the top
bit of the mantissa must be SET to indicate a SNaN. */
So, definetely the numeric_limits for c++ is broken for the loongson2f.
It may be broken in C headers too.
And I don't know if it is broken for all mips, loongson2f is different from the
other mips, or what.
Anyone knows more details? I'll keep investigating a bit more.
Here is the C++ code I used. Change it at will to test:
----------------
#include <limits>
#include <math.h>
#include <iostream>
double madd(double a, double b, double c)
{
return a*b+c;
}
int main()
{
double z = 0;
double f = std::numeric_limits<double>::quiet_NaN();
double g = madd(z, 1, 1);
std::cout << "primer: " << g << std::endl;
f = std::numeric_limits<double>::signaling_NaN();
g = madd(z, f, f);
std::cout << "segon: " << g << std::endl;
return 0;
}
----------------
Regards,
Lluís.
--
You received this message because you are subscribed to the Google Groups
"loongson-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/loongson-dev?hl=en.