Mail Archives: pgcc/1998/09/03/09:01:26
X-pop3-spooler: | POP3MAIL 2.1.0 b 4 980420 -bs-
|
Date: | Thu, 03 Sep 1998 10:48:21 +0100
|
Date-warning: | Date header was inserted by risoe.dk
|
From: | Kristian Nielsen <kristian DOT nielsen AT risoe DOT dk>
|
Subject: | Found problem with -fpeep-spills in PGCC 2.90.29
|
To: | beastium-list AT Desk DOT nl
|
Message-id: | <01J1D87D9B928X38A4@risoe.dk>
|
MIME-version: | 1.0 (generated by tm-edit 7.106)
|
Sender: | Marc Lehmann <pcg AT goof DOT com>
|
Status: | RO
|
Lines: | 102
|
Hi,
I found a way to reproduce a problem with the -fpeep-spills optimization
in pgcc-2.90.29 980515 (egcs-1.0.3 release). The example is reasonably
short, and the assembler output with and without -fpeep-spills have
essentially only a single difference (an extra spill and reload without
-fpeep-spills), so I hope it will be useful to find the bug.
Compiled with
gcc -O3 -o pgcc-bug-bad pgcc-bug.c -lm
the program below gives the (wrong) output
Before: vy = 5
After: vy = 1000
Compiled with
gcc -O3 -fno-peep-spills -o pgcc-bug-ok pgcc-bug.c -lm
the program gives the (correct) output
Before: vy = 5
After: vy = 5
Program text and assembler output with and without -fpeep-spills are
also available via WWW on
http://www.diku.dk/~bombadil/pgcc-bug.c
http://www.diku.dk/~bombadil/pgcc-bug-bad.S
http://www.diku.dk/~bombadil/pgcc-bug-ok.S
Hope this helps,
- Kristian.
------------------------------------------------------------------------
typedef double MCNUM;
typedef struct {MCNUM x, y, z;} Coords;
typedef MCNUM Rotation[3][3];
/* Add two coordinates */
static Coords
coords_add(Coords a, Coords b)
{
Coords c;
c.x = a.x + b.x;
c.y = a.y + b.y;
c.z = a.z + b.z;
return c;
}
/* Multiply matrix and corrdinate vector */
static Coords
rot_apply(Rotation t, Coords a)
{
Coords b;
b.x = t[0][0]*a.x + t[0][1]*a.y + t[0][2]*a.z;
b.y = t[1][0]*a.x + t[1][1]*a.y + t[1][2]*a.z;
b.z = t[2][0]*a.x + t[2][1]*a.y + t[2][2]*a.z;
return b;
}
static void
mccoordschange(Coords a, Rotation t, double *x, double *y, double *z,
double *vx, double *vy, double *vz, double *time,
double *s1, double *s2)
{
Coords b, c;
b.x = *x;
b.y = *y;
b.z = *z;
c = rot_apply(t, b);
b = coords_add(c, a);
*x = b.x;
*y = b.y;
*z = b.z;
b.x = *vx;
b.y = *vy;
b.z = *vz;
c = rot_apply(t, b);
*vx = c.x;
*vy = c.y;
*vz = c.z;
}
Coords a = {0, 0, 1000};
Rotation t = { {1,0,0}, {0,1,0}, {0,0,1} };
main()
{
double x = 10, y = 20, z = 0, vx = 3, vy = 5, vz = 50;
double time = 0, s1 = 0, s2 = 0;
printf("Before: vy = %g\n", vy);
mccoordschange(a, t, &x, &y, &z, &vx, &vy, &vz, &time, &s1, &s2);
printf("After: vy = %g\n", vy);
}
- Raw text -