http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49257
Summary: -mfpmath=sse generates x87 instructions on 32 bits OS Product: gcc Version: 4.5.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: olivier_ma...@mentor.com Created attachment 24408 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24408 simple reproducer Hi, Please find attached a simple C program that shows the issue. I compile it that way: gcc -O0 simple.c -mfpmath=sse -msse3 -o ok.exe ./ok.exe returns the correct value gcc -O0 simple.c -mfpmath=sse -msse3 -DRETURN_NAN -o nan.exe ./nan.exe returns a NAN Both exe use some gcc intrinsic that change the FP stack into mmx registers. It is expected that if I call a libc function (like printf) without restoring the stack to its original state (using emms) then I'll have a wrong behavior. But, here, because of the following assembly code: .L4: fildq 72(%esp) cmpl $0, 76(%esp) jns .L3 fldt .LC2 faddp %st, %st(1) .L3: fstpl 24(%esp) movsd 24(%esp), %xmm0 mulsd 56(%esp), %xmm0 movsd %xmm0, 40(%esp) movl 68(%esp), %eax movl 4(%eax), %edx movl (%eax), %eax movl 52(%esp), %ecx movl %eax, 16(%esp) movl %edx, 20(%esp) movq 16(%esp), %mm0 movntq %mm0, (%ecx) addl $1, 72(%esp) adcl $0, 76(%esp) .L2: cmpl $0, 76(%esp) jb .L4 cmpl $0, 76(%esp) ja .L6 cmpl $9, 72(%esp) jbe .L4 I've got a NAN why I shouldn't !? The instruction that generates that x87 code is the line (double)i * coeff; where i is an unsigned long long and coeff is a double. It works well if for instance 'i' is a long/int/unsigned int. Maybe that behavior is expected ? BR Olivier