This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/46993] New: Optimization on i386 lead to user-visible traps during floating-point operations


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]