prerelease-3 haifa-scheduler PentiumPro Optimizer bug

Gerhard Heinzel ghh@mpq.mpg.de
Fri Nov 27 06:53:00 GMT 1998


Dear All,

The bug I have reported on Nov 16th
( http://www.cygnus.com/ml/egcs-bugs/1998-Nov/0476.html )

is still present in the latest 
egcs-1.1.1-prerelease-3 , if I enable the haifa-scheduler.

I have run configure with

--enable-haifa

and it has (correctly) determined the following system:

--host=i686-pc-linux-gnulibc1

(A short reminder: The combination     -O -march=i686
produces buggy floating-point code)

Sorry I know not enough about the compiler to find the bug myself, but maybe
someone else can do that?

Gerhard

Here is the offending program:

#include <stdio.h>
#include <math.h>
#define SIZE 10

int
main (void)
{
  int i, j, k;
  double a[SIZE * SIZE], ainv[SIZE * SIZE];
  double diff, sum, soll, maxd;

  /* matrix addressing : a(i,j) = a[n*i+j] */

  /* Normally here 'a' is a double matrix and 'ainv' its inverse */
  /* For testing, set 'a' and 'ainv' as unity matrices */
  for (i = 0; i < SIZE; i++)
    for (j = 0; j < SIZE; j++)
      a[i * SIZE + j] = ainv[i * SIZE + j] = ((i == j) ? 1 : 0);

  /* compute the product a*ainv element by element and compare to
     unity matrix */

  maxd = 0;			/* maximum of difference */
  for (i = 0; i < SIZE; i++)
    for (j = 0; j < SIZE; j++)
      /* compute element (i,j) of product */
      {
/*1*/	sum = 0;
/*2*/	soll = ((i == j) ? 1 : 0);	/* this should be the result */
	for (k = 0; k < SIZE; k++)
	  sum += a[i * SIZE + k] * ainv[k * SIZE + j];
	diff = fabs (sum - soll);	/* measure difference */
	if (diff > maxd)	/* record maximum difference */
	  maxd = diff;
      }
  printf ("maxd=%g \n", maxd);
  return 0;
}

It should correctly print '0', but wrongly prints 'NaN', if compiled with

gcc -o err -march=i686 -O err.c



=====================================================================
 Gerhard Heinzel                            E-mail:   ghh@mpq.mpg.de
 Max-Planck-Institut fuer Quantenoptik   Phone: +49(89)32905-268/252
 Hans-Kopfermann-Str. 1            Phone (30m Lab): +49(89)3299-3282
 D-85748 Garching                              Fax: +49(89)32905-200  
 Germany                           http://www.geo600.uni-hannover.de
=====================================================================




More information about the Gcc-bugs mailing list