public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: ghh@mpq.mpg.de
To: gcc-gnats@gcc.gnu.org
Subject: optimization/5017: i386 floating point optimization
Date: Wed, 05 Dec 2001 04:46:00 -0000	[thread overview]
Message-ID: <200112051238.fB5Cc4W25044@lp27.amp.uni-hannover.de> (raw)


>Number:         5017
>Category:       optimization
>Synopsis:       i386 floating point optimization
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 05 04:46:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Gerhard Heinzel
>Release:        3.0.2
>Organization:
Albert Einstein Institut Hannover, Germany
>Environment:
System: Linux lp27 2.4.4-4GB #1 Wed May 16 00:37:55 GMT 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure 
>Description:
The included small test program fails when compiled with
gcc -O3 -o mybes mybes.c -lm
It works with -O0.
indication of failure is the following output.
The first line starting with "5.00" is garbage.
There should not be any "nan"

4.00  18      4.0944813915730677499e-11          11.301921952136330496
4.00  19      4.3099804121821765789e-12          11.301921952136330496
4.00  20      4.3099804121821765788e-13          11.301921952136330496
4.00  21      4.1047432496973110274e-14          11.301921952136330496
4.00  22      3.7315847724521009341e-15          11.301921952136330496
4 11.301921952136330773 6.62406158447265625
5.00   1                            nan                              1
5.00   2                            nan                            nan
5.00   3                            nan                            nan
5.00   4                            nan                            nan
5.00   5                            nan                            nan

>How-To-Repeat:

#include <stdio.h>
double
mybesi0 (double x)
{
  int k = 0;
  long double sum = 0;
  long double add = 1;
  long double x2 = x / 2.;

  if (x == 0)
    return 1;
  if (x < 0)
    x = -x;
  if (x > 50)
    {
      fprintf (stderr, "argument to mybesi0 too large:%g\n", x);
      exit (1);
    }
  add = 1;
  for (;;)
    {
      sum += add * add;
      add /= (++k);
      add *= x2;
      printf("%4.2f %3d %30.20Lg %30.20Lg\n",x,k,add,sum);
      if (add / sum < 1e-15)
	break;
    }
  return sum;
}

float
bessi0 (float x)
{
  float ax, ans;
  double y;

  if ((ax = fabs (x)) < 3.75)
    {
      y = x / 3.75;
      y *= y;
      ans = 1.0 + y * (3.5156229 + y * (3.0899424 + y * (1.2067492
		  + y * (0.2659732 + y * (0.360768e-1 + y * 0.45813e-2)))));
    }
  else
    {
      y = 3.75 / ax;
      ans = (exp (ax) / sqrt (ax)) * (0.39894228 + y * (0.1328592e-1
		   + y * (0.225319e-2 + y * (-0.157565e-2 + y * (0.916281e-2
	       + y * (-0.2057706e-1 + y * (0.2635537e-1 + y * (-0.1647633e-1
						  + y * 0.392377e-2))))))));
    }
  return ans;
}

void
main (void)
{
  double x;
  for (x = 0; x <= 50; x += 1)
   printf ("%.20g %.20g %.20g\n", x, mybesi0 (x), bessi0(x)); 
}


>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-12-05 12:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-05  4:46 ghh [this message]
2001-12-05 20:14 rodrigc
2001-12-05 20:16 rodrigc

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=200112051238.fB5Cc4W25044@lp27.amp.uni-hannover.de \
    --to=ghh@mpq.mpg.de \
    --cc=gcc-gnats@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).