why does gcc need -fno-trapping-math to generate roundsd instructions?
Jay Foad
jay.foad@gmail.com
Tue Jan 14 14:53:00 GMT 2014
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.
More information about the Gcc-help
mailing list