why does gcc need -fno-trapping-math to generate roundsd instructions?

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

 



I'm using GCC 4.8.1 with eglibc 2.17 on an Intel CPU with SSE 4.1.

Given this source:

#include <math.h>
double f(double x){return floor x;}

gcc -msse4.1 -O -S generates:

f:
subq $8, %rsp
call floor
addq $8, %rsp
ret

It seems I need to add -fno-trapping-math to get inline code:

f:
roundsd $1, %xmm0, %xmm0
ret

But why? If I run the first version under a debugger, the call to
"floor" eventually resolves to eglibc's __floor_sse41, which just does
this:

roundsd $0x1,%xmm0,%xmm0
retq

So what is -ftrapping-math really buying me? Why can't the compiler
generate roundsd inline in all cases?

Thanks,
Jay.




[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