public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Gcc bug with mfpmath=sse and movntq ?
@ 2011-05-31 20:15 Olivier Maury
  0 siblings, 0 replies; only message in thread
From: Olivier Maury @ 2011-05-31 20:15 UTC (permalink / raw)
  To: gcc-help

Hi,

I'm still doing some experiments using the movntq instruction on a 32 
bits OS with gcc 4.5.1

Using the following code I have a NAN and I don't understand what I'm 
doing wrong :

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

typedef struct
{
   double data1;
} ty_data;

static ty_data s_data;

void *strange_fnc()
{

   double in;
   long long unsigned int *vin = (long long unsigned int *)&in;
   unsigned long long i;

   double *data;
   double coeff = 1.;

   data = &(s_data.data1);

   for (i = 0; i < 10; ++i)
   {
     in = (double)i * coeff; /* <-- that instruction generates a x87 
instruction !? */
     __builtin_ia32_movntq((long long unsigned int*)(data), *vin);
#ifdef FORCE_EMMS
     __builtin_ia32_emms();
#endif
   }
   __builtin_ia32_emms();

   return NULL;
}


int main(int argc, char **argv)
{
   memset(&s_data, 0, sizeof(ty_data));

   strange_fnc();

   printf("1- %e\n",
          s_data.data1);

   return 0;
}

<380> gcc -g -O simple.c -mfpmath=sse -msse -msse2 -msse3 -malign-double 
-DFORCE_EMMS
<381> ./a.out
1- 9.000000e+00

<382> gcc -g -O simple.c -mfpmath=sse -msse -msse2 -msse3 -malign-double
<383> ./a.out
1- nan

<387> gcc -g -O simple.c -mfpmath=sse -msse -msse2 -msse3 -malign-double 
-mno-80387
1- 4.446591e-323

Since I ask gcc to explicitly use the sse registers I don't understand 
why it generates a x87 instruction for the type cast !
What am I missing ? Is it a bug ?

Thanks for your help.

Olivier

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-31 15:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-31 20:15 Gcc bug with mfpmath=sse and movntq ? Olivier Maury

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).