This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/34170] New: wrong code: mmx operation changes double to nan
- From: "tijl at ulyssis dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Nov 2007 00:17:34 -0000
- Subject: [Bug c/34170] New: wrong code: mmx operation changes double to nan
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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