public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jay Foad <jay.foad@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: why does gcc need -fno-trapping-math to generate roundsd instructions?
Date: Tue, 14 Jan 2014 14:53:00 -0000	[thread overview]
Message-ID: <CANd1uZmNiFe_vBqKVu+jqp+Y-kgU5QDkWBisDh5iYHB6tdTfzg@mail.gmail.com> (raw)

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.

             reply	other threads:[~2014-01-14 14:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-14 14:53 Jay Foad [this message]
2014-01-15 16:13 ` Marc Glisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANd1uZmNiFe_vBqKVu+jqp+Y-kgU5QDkWBisDh5iYHB6tdTfzg@mail.gmail.com \
    --to=jay.foad@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).