[Bug c/34170] New: wrong code: mmx operation changes double to nan
tijl at ulyssis dot org
gcc-bugzilla@gcc.gnu.org
Wed Nov 21 00:17:00 GMT 2007
I was working on a little routine to generate random vectors of two doubles,
but it produced nothing but {nan,nan}. It was a simple linear congruential
random number generator, so all it did was operate on a seed (a vector of two
integers) and then convert that to double using an SSE2 intrinsic. The result
was then multiplied by (1.0 / 2147483648.0) to give random numbers between -1
and 1. It was (1.0 / 2147483648.0) that turned out to be converted to nan.
I've reduced it to a minimal test case below. It prints out nan instead of 1.0.
You can compile it with: `cc -O0 -Wall -mmmx -o test test.c`
--- begin test.c ---
#include <stdio.h>
#include <mmintrin.h>
static __m64 s;
int main( int argc, char **argv ) {
__m64 a;
double d;
d = 1.0;
s = a + a;
printf( "%e\n", d );
return 0;
}
--- end test.c ---
--
Summary: wrong code: mmx operation changes double to nan
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tijl at ulyssis dot org
GCC build triplet: i386-unknown-freebsd7
GCC host triplet: i386-unknown-freebsd7
GCC target triplet: i386-unknown-freebsd7
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34170
More information about the Gcc-bugs
mailing list