Gcc bug with mfpmath=sse and movntq ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux