public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/12199] New: [3.3-hammer regression] long double miscompilation in gsl/amd64
@ 2003-09-06 23:17 gbeauchesne at mandrakesoft dot com
  2003-09-07  0:52 ` [Bug optimization/12199] " pinskia at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: gbeauchesne at mandrakesoft dot com @ 2003-09-06 23:17 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: [3.3-hammer regression] long double miscompilation in
                    gsl/amd64
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gbeauchesne at mandrakesoft dot com
                CC: aj at suse dot de,gcc-bugs at gcc dot gnu dot org,jh at
                    suse dot cz
  GCC host triplet: x86_64-unknown-linux-gnu

Hi,

The following testcase reduced from gsl is miscompiled only with 3.3-hammer branch as of today. 
This is a  regression from plain 3.3-branch. Sounds like conversion from double to long double 
delta variable gets mad.

The bug is exhausted at -O2 and vanishes at -O1 or with extra -fno-regmove.
---
extern void abort (void);

static double
fabs (double x)
{
  return x < 0 ? -x : x;
}

static void
check (double result, double expected, double relative_error)
{
  int status = -1;

  if (result < 0 || result > 0)
	status = (fabs(result - expected)/fabs(expected) > relative_error);

  if (status)
	abort ();
}

int
main (void)
{
  const int na = 14;

  const double rawa[] =
  {.0421, .0941, .1064, .0242, .1331,
   .0773, .0243, .0815, .1186, .0356,
   .0728, .0999, .0614, .0479};

  double rel = 1e-10;

  {
	const double mean = 0.0728;
	const double expected = 0.00113837428571429;
	long double variance = 0 ;
	int i;

	for (i = 0; i < na; i++)
	  {
		const long double delta = (rawa[i] - mean);
		variance += (delta * delta - variance) / (i + 1);
	  }

    check (variance, expected, rel);
  }

  return 0;
}


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

end of thread, other threads:[~2004-04-21  1:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-06 23:17 [Bug optimization/12199] New: [3.3-hammer regression] long double miscompilation in gsl/amd64 gbeauchesne at mandrakesoft dot com
2003-09-07  0:52 ` [Bug optimization/12199] " pinskia at gcc dot gnu dot org
2003-09-07  7:52 ` gbeauchesne at mandrakesoft dot com
2003-09-09 13:53 ` gbeauchesne at mandrakesoft dot com
2003-09-09 15:01 ` jh at suse dot cz
2003-10-01 15:06 ` zlomek at gcc dot gnu dot org
2003-12-09 18:23 ` dhazeghi at yahoo dot com
2004-04-21  2:16 ` pinskia 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).