public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* why does gcc need -fno-trapping-math to generate roundsd instructions?
@ 2014-01-14 14:53 Jay Foad
  2014-01-15 16:13 ` Marc Glisse
  0 siblings, 1 reply; 2+ messages in thread
From: Jay Foad @ 2014-01-14 14:53 UTC (permalink / raw)
  To: gcc-help

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-15 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-14 14:53 why does gcc need -fno-trapping-math to generate roundsd instructions? Jay Foad
2014-01-15 16:13 ` Marc Glisse

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).