public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "arseny.klimovsky at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/46993] New: Optimization on i386 lead to user-visible traps during floating-point operations
Date: Fri, 17 Dec 2010 16:34:00 -0000	[thread overview]
Message-ID: <bug-46993-4@http.gcc.gnu.org/bugzilla/> (raw)

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

           Summary: Optimization on i386 lead to user-visible traps during
                    floating-point operations
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: arseny.klimovsky@gmail.com


Version:
$ g++-4.5.2 -v
Using built-in specs.
COLLECT_GCC=g++-4.5.2
COLLECT_LTO_WRAPPER=/opt/gcc-4.5.2/libexec/gcc/x86_64-unknown-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.5.2/configure --prefix /opt/gcc-4.5.2/
Thread model: posix
gcc version 4.5.2 (GCC)

Command:
$ g++ -m32 -fsignaling-nans -O1 -c -S -o simple.s simple.cpp 

Consider a simple function, which copies one value from double array c to
double array a.

#include <string.h>
void copy (double * a, double * c)
{
  double b[100];
  memcpy (b, c, sizeof (double));
  memcpy (a, b, sizeof (double));
}

This will generate code
        .cfi_startproc
        pushl   %ebp
        .cfi_def_cfa_offset 8
        movl    %esp, %ebp
        .cfi_offset 5, -8
        .cfi_def_cfa_register 5
        movl    12(%ebp), %eax
        fldl    (%eax)
        movl    8(%ebp), %eax
        fstpl   (%eax)
        popl    %ebp
        .cfi_restore 5
        .cfi_def_cfa 4, 4
        ret
        .cfi_endproc

Here, if c[0] is a NaN, and FPU exception mask is set, an FPE will occur.
In gcc 4.4 and earlier I could use memcpy instead of operator= to be sure, that
no floating point operations will be generated.
Now I don't know how to safely copy values from local double buffer (or a
single variable) to some address without floating point operations.


             reply	other threads:[~2010-12-17 16:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-17 16:34 arseny.klimovsky at gmail dot com [this message]
2011-01-12 12:05 ` [Bug target/46993] " arseny.klimovsky at gmail dot com
2024-03-12 22:12 ` pinskia at gcc dot gnu.org

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=bug-46993-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).