public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/33088]  New: [4.1/4.2/4.3 Regression] spurious exceptions with -ffloat-store
@ 2007-08-16 12:14 jsm28 at gcc dot gnu dot org
  2007-08-17  9:27 ` [Bug middle-end/33088] " pinskia at gcc dot gnu dot org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2007-08-16 12:14 UTC (permalink / raw)
  To: gcc-bugs

Since RTH's patch <http://gcc.gnu.org/ml/gcc-patches/2005-06/msg00860.html>,
stores to the real or imaginary part of a complex variable are represented
using a load of the other part and a COMPLEX_EXPR.

If the variable is not yet initialized, and the load of the other part does not
get optimized away, this can yield spurious floating-point exceptions (in
particular, loading a signaling NaN on the x87 raises the "invalid" exception).
 This can happen with -ffloat-store (I don't have any proof that this is
restricted to -ffloat-store, but haven't observed the problem without this
option).

I observed the problem originally as a failure of glibc's test-double, which is
built with -ffloat-store and forms complex values by setting the real and
imaginary parts separately.  The following testcase reproduces it on
i686-pc-linux-gnu, with trunk (-ffloat-store together with any of -O1 -O2 -O3
-Os), 4.2 branch (same options), 4.1 branch (-float-store -O1), but not for 4.0
(which predates the above mentioned patch) with any of those options.  An
equivalent x86-specific test could of course be written without use of
<fenv.h>.

#include <fenv.h>
#include <stdlib.h>

volatile int x[1024];

void __attribute__((noinline))
fill_stack (void)
{
  volatile int y[1024];
  int i;
  for (i = 0; i < 1024; i++)
    y[i] = 0x7ff00000;
  for (i = 0; i < 1024; i++)
    x[i] = y[i];
}

volatile _Complex double vc;

void __attribute__((noinline))
use_complex (_Complex double c)
{
  vc = c;
}

double t0, t1, t2, t3;

#define USE_COMPLEX(X, R, C) \
  do { __real__ X = R; __imag__ X = C; use_complex (X); } while (0)

void __attribute__((noinline))
use_stack (void)
{
  _Complex double a, b, c, d;
  USE_COMPLEX (a, t0, t1);
  USE_COMPLEX (b, t1, t2);
  USE_COMPLEX (c, t2, t3);
  USE_COMPLEX (d, t3, t0);
}

int
main (void)
{
  fill_stack ();
  feclearexcept (FE_INVALID);
  use_stack ();
  if (fetestexcept (FE_INVALID))
    abort ();
  exit (0);
}


-- 
           Summary: [4.1/4.2/4.3 Regression] spurious exceptions with -
                    ffloat-store
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jsm28 at gcc dot gnu dot org


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


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

end of thread, other threads:[~2009-03-30 22:16 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-16 12:14 [Bug middle-end/33088] New: [4.1/4.2/4.3 Regression] spurious exceptions with -ffloat-store jsm28 at gcc dot gnu dot org
2007-08-17  9:27 ` [Bug middle-end/33088] " pinskia at gcc dot gnu dot org
2007-08-17 10:37 ` joseph at codesourcery dot com
2007-09-11 11:48 ` jsm28 at gcc dot gnu dot org
2007-09-28  3:59 ` mmitchel at gcc dot gnu dot org
2007-11-15 15:53 ` rguenth at gcc dot gnu dot org
2007-11-16 14:51 ` jakub at gcc dot gnu dot org
2007-11-16 16:53 ` joseph at codesourcery dot com
2007-12-02 10:13 ` ebotcazou at gcc dot gnu dot org
2007-12-02 10:13 ` ebotcazou at gcc dot gnu dot org
2007-12-03 11:14 ` rguenth at gcc dot gnu dot org
2007-12-03 11:17 ` ismail at pardus dot org dot tr
2007-12-05 10:13 ` ebotcazou at gcc dot gnu dot org
2007-12-05 10:44 ` pinskia at gcc dot gnu dot org
2007-12-13 21:49 ` ebotcazou at gcc dot gnu dot org
2007-12-13 21:54 ` [Bug middle-end/33088] [4.1/4.2 regression] " ebotcazou at gcc dot gnu dot org
2008-03-13 17:00 ` pinskia at gcc dot gnu dot org
2008-03-13 17:03 ` rguenther at suse dot de
2008-03-14 17:00 ` [Bug middle-end/33088] [4.2 Regression] " rguenth at gcc dot gnu dot org
2008-03-15  0:44 ` jsm28 at gcc dot gnu dot org
2008-03-15  0:54 ` jsm28 at gcc dot gnu dot org
2008-05-19 20:29 ` jsm28 at gcc dot gnu dot org
2009-03-30 22:16 ` jsm28 at gcc dot gnu dot org

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