Bug in egcs1.1.1pre on i686/Linux with loop unrolling.
Hans Dolfing
Hans.Dolfing@home.ivm.de
Thu Nov 5 22:00:00 GMT 1998
Hi,
Just found an interesting bug: The combination of
-march=pentiumpro and loop unrolling produces
some bogus results while -march=pentium is fine.
Testcase + details + example output is included.
Best regards,
Hans
Testcase: ----------------------------------------------------
#include <stdio.h>
int main(void)
{
int i;
for (i=0; i<16; i++)
{
int j = i/4;
fprintf(stderr,"i=%d,j=%d,i/4=%d\n",i,j,i/4);
}
return 0;
}
Details ---------------------------------------------------
egcs version is :
Reading specs from
/usr/local/lib/gcc-lib/i686-pc-linux-gnulibc1/egcs-2.91.58/specs
gcc version egcs-2.91.58 19981101 (egcs-1.1.1 pre-release)
Compiler built from egcs-1.0.3a sources with [gcc/g++/g77] diffs
to egcs-1.1b and diffs to egcs-1.1.1 prerelease.
config.guess: i686-pc-linux-gnulibc1
Configured with --enabled-haifa --enable-shared.
Here is the story (and a testcase):
1. The following versions are ok:
gcc -o t -O2 t.c -lm
gcc -o t -O2 -march=pentium -funroll-all-loops t.c -lm
gcc -o t -O2 -march=pentium -freduce-all-givs t.c -lm
2. These compile jobs give completely bogus results (see appended
output examples).
gcc -o t -O2 -march=pentiumpro -funroll-all-loops t.c -lm
gcc -o t -O2 -march=pentiumpro -funroll-loops t.c -lm
gcc -o t -O2 -march=pentiumpro -freduce-all-givs t.c -lm
Note: I don't know if it is related but there was
a bootstrapping problem. In the file ./objdir/gcc/auto-host.h,
the text 'TOP' was somehow inluced (which is not valid
ANSI-C). Manual removing of only these 3 characters allows
the bootstrapping to proceed. I just mention this for
the sake of completeness because there is always a chance
that one problem relates to another :(
Output examples:
----------------- 1 -----------------
Compile : gcc -o t -O2 t.c -lm
Run : t
Output : ( OK )
i=0,j=0,i/4=0
i=1,j=0,i/4=0
i=2,j=0,i/4=0
i=3,j=0,i/4=0
i=4,j=1,i/4=1
i=5,j=1,i/4=1
i=6,j=1,i/4=1
i=7,j=1,i/4=1
i=8,j=2,i/4=2
i=9,j=2,i/4=2
i=10,j=2,i/4=2
i=11,j=2,i/4=2
i=12,j=3,i/4=3
i=13,j=3,i/4=3
i=14,j=3,i/4=3
i=15,j=3,i/4=3
----------------- 2 -----------------
Compile : gcc -o t -O2 -march=pentiumpro -funroll-loops t.c -lm
Run : t
Output : (Bogus)
i=0,j=0,i/4=0
i=1,j=1,i/4=1
i=2,j=0,i/4=0
i=3,j=0,i/4=0
i=4,j=1,i/4=1
i=5,j=2,i/4=2
i=6,j=1,i/4=1
i=7,j=1,i/4=1
i=8,j=2,i/4=2
i=9,j=3,i/4=3
i=10,j=2,i/4=2
i=11,j=2,i/4=2
i=12,j=3,i/4=3
i=13,j=4,i/4=4
i=14,j=3,i/4=3
i=15,j=3,i/4=3
----------------- 3 -----------------
Compile : gcc -o t -O2 -march=pentiumpro -freduce-all-givs t.c -lm
Run : t
Output :
i=0,j=0,i/4=0
i=1,j=1,i/4=1
i=2,j=1,i/4=1
i=3,j=1,i/4=1
i=4,j=1,i/4=1
i=5,j=2,i/4=2
i=6,j=2,i/4=2
i=7,j=2,i/4=2
i=8,j=2,i/4=2
i=9,j=3,i/4=3
i=10,j=3,i/4=3
i=11,j=3,i/4=3
i=12,j=3,i/4=3
i=13,j=4,i/4=4
i=14,j=4,i/4=4
i=15,j=4,i/4=4
More information about the Gcc-bugs
mailing list