http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44578



Teresa Johnson <tejohnson at google dot com> changed:



           What    |Removed                     |Added

----------------------------------------------------------------------------

                 CC|                            |tejohnson at google dot com



--- Comment #7 from Teresa Johnson <tejohnson at google dot com> 2013-04-29 
16:44:10 UTC ---

*** Update on below text: As of r198401 the problem is hidden unless compiling

with -mtune=athlon64 due to some tuning changes. ***



I have another instance of this issue. Trunk is generating move instructions to

implement an inlined memcpy. The move instructions use the MMX registers, but

no EMMS instruction is generated. My testcase then calls a libm function that

uses the FPU, which returns incorrect results. This worked with an older gcc

4.7 based compiler, which didn't use MMX registers.



The compiler was configured for x86_64-unknown-linux-gnu. The testcase was

compiled with -O2.



$ cat test.cc

#include <stdlib.h>

#include <string.h>

#include <math.h>

#include <stdio.h>



namespace {

volatile double dd = 0.080553657784353652;

double dds, ddc;

}



unsigned long long test(float num) {

  if (num < 0) {

    num = 0;

  }



  unsigned int i;

  memcpy(&i, &num, sizeof(unsigned int));

  unsigned long long a = i;



  sincos(dd, &dds, &ddc);

  if (isnan(dds) || isnan(ddc))

  {

    printf ("Failed\n");

    exit (1);

  }

  return a;

}



$ cat test_main.cc

#include <stdio.h>



extern unsigned long long test(float num);

int main()

{

  unsigned long long h = test(1);

  printf ("Passed\n");

}



$ g++ -O2 test*.cc -mtune=athlon64 (See earlier note on why -mtune=athlon64 is

needed here)



$ a.out

Failed

Reply via email to