mark@AI.MIT.EDU (Mark Mills) (06/02/89)
I have found what appears to be a bug in gcc-1.35. However,
it is such a simple thing surely it is not. Here are some
examples which demonstrate the "bug". Each was compiled
with: gcc -O e1.c. (The as listings by: gcc -O -S e1.c)
This gcc was brought up on a R3V5.1 Unix system using pcc.
I am using the native as and ld. The processor is 68030/68882.
This same R3V5.1/pcc compiles and runs TeX, X11, etc, so I
believe that much is ok. Gcc compiled itself fine during
stage1 build, except c-parse.tab.c, expr.c and insn-recog.c
would not compile with both -g and -O options. Either just
-g or -O worked fine by itself. These modules were built with
-g for the stage1 build. The stage1 build was what was used
to generate the sequences below.
It would be nice if there was a gcc test suite that had
known programs to test against. Know you always wonder whether
it is gcc or your "port" which is causing the problems.
Regards and keep up the good work,
Mark Mills
---
mark@motcoh.UUCP
{osu-cis, mcdchg}!motcoh!mark
=================== Example 1 =========================
main()
{
float M;
int N;
N = 1000000;
M = (float)N;
printf ("M = %e\n",M);
printf ("N = %e\n",(float)N);
}
M = 1.000000e+06
N = 1.000000e+06
text
L%C0:
byte 77,32,61,32,37,101,10,0
L%C1:
byte 78,32,61,32,37,101,10,0
even
global main
main:
link.w %a6,&0
fmovem &0x4,-(%sp)
mov.l %d2,-(%sp)
fmove.l &1000000,%fp2
fmove.d %fp2,-(%sp)
pea L%C0
move.l &printf,%d2
move.l %d2,%a0
jsr (%a0)
fmove.d %fp2,-(%sp)
pea L%C1
move.l %d2,%a0
jsr (%a0)
mov.l -16(%a6),%d2
fmovm.x -12(%a6),&0x20
unlk %a6
rts
================= Example 2 ======================
main()
{
float M;
int N;
N = 1000000;
M = 1000000.0;
printf ("M = %e\n",M);
printf ("N = %e\n",(float)N);
}
M = 0.000000e+00
N = 1.000000e+06
text
L%C0:
byte 77,32,61,32,37,101,10,0
L%C1:
byte 78,32,61,32,37,101,10,0
even
global main
main:
link.w %a6,&0
movm.l &0x3000,-(%sp)
move.l &1000000,%d2
fmove.s &0x0,%fp1
fmove.d %fp1,-(%sp)
pea L%C0
move.l &printf,%d3
move.l %d3,%a0
jsr (%a0)
fmove.l %d2,%fp0
fmove.d %fp0,-(%sp)
pea L%C1
move.l %d3,%a0
jsr (%a0)
movm.l -8(%a6),&0xc
unlk %a6
rts
================ Example 3 ==================
main()
{
float M;
int N;
N = 1000000;
M = 1.0e+06;
printf ("M = %e\n",M);
printf ("N = %e\n",(float)N);
}
Produces the same printf output and identical asm code.
================== Example 4 ======================
#define M 1000000.0
main()
{
printf ("M = %e\n",M);
}
M = 1.000000e+06
text
L%C0:
byte 77,32,61,32,37,101,10,0
even
global main
main:
link.w %a6,&0
clr.l -(%sp)
move.l &1093567616,-(%sp)
pea L%C0
jsr printf
unlk %a6
rts
================= Example 5 ==================
#define M 1000000.0
main()
{
long num = 50;
float oops;
oops = num * M;
printf ("oops = %e\n",oops);
}
oops = 4.275000e+04
text
L%C0:
byte 111,111,112,115,32,61,32,37
byte 101,10,0
even
global main
main:
link.w %a6,&0
fmove.l &50,%fp0
fmul.d &0x408ab800000000,%fp0
fmove.s %fp0,%d0
fmove.s %d0,%fp1
fmove.d %fp1,-(%sp)
pea L%C0
jsr printf
unlk %a6
rts