Red Hat Bugzilla – Bug 83703
gcc3 generates wrong code with -march=pentium4
Last modified: 2007-04-18 12:50:49 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130
Description of problem:
I have downloaded http://www.daimi.au.dk/~aske/mk/mk244r3.tar.gz (ant simulator)
and added a couple of ants of my own design and made some test-runs.
If I compile the package as it is out of the box, everything is fine (even
inkluding my own ants). If I add -march=pentium4 and run with the exact same
options, a different result is obtained.
The software requires no special attention, i.e. it compiles out of the box on
several platforms and the result is the same on all platforms, execept on RedHat
Linux 8.0 with -march=pentium4 added.
I haven't located the actual problem, but as gcc (according to their homepage)
are up to 3.2.2 with several pentium4 fixes, this problem might already be fixed.
I am unsure if it is safe to upgrade gcc using the rawhide packages so I don't
know if they contain the fault as well.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Download package.
2. Compile with -march=pentium4
3. Compare testrun with a run without -march=pentium4
Actual Results: Different result is obtained, i.e. the simluation turns out
Expected Results: The same result should be obtained (running on sun solaris
produces the same result as a redhat linux 8.0 run without -march=pentium4).
Knowing that -march=pentium4 is faulty is actually quite severe as gcc is able
to optimise code for pentium4 quite significantly (have seen nearly double
performance with -march=pentium4).
It is certainly safe to upgrade to gcc from rawhide.
It can be an application bug too, doesn't have to be a compiler bug
(e.g. some strict aliasing bugs only show up depending on the exact insn scheduling).
If you could do a binary search to find out which single file matters
here (always compile some files without -march=pentium4 and some files with that
option), I could check it out.
For some reason I have completely missed the fact that -O3 was given to gcc. I have tried with -O2 and -O and also with -march=pentium4 and found that only -O and "-O -march=pentium4" give the same result. -O2, "-O2 -march=pentium4", -O3, "-O3 -march=pentium4" give different results and the latter (-O3 -march=pentium4) gives results not similar to any of the other runs.
I would like to assist in finding the cause of the bug, but it appears that -O2 (with or without -march=pentium4) produces faulty code (at least different to -O (with or without -march=pentium4).
Now, gain knowledge about what the result would be without -O, I removed it and recompiled only to have gcc quit with a compiler error:
gcc -fsigned-char -Wall -I. -DNDEBUG -c -o Racer/BlackHole.o Racer/BlackHole.c
Racer/BlackHole.c: In function `BlackHole_CopyIn':
Racer/BlackHole.c:8: Internal compiler error in instantiate_virtual_regs_1, at function.c:3972
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugzilla.redhat.com/bugzilla/> for instructions.
make: *** [Racer/BlackHole.o] Error 1
Download the above package and study BlackHole.c (very small file (475 bytes), but nearly unreadable).
No crash with gcc 3.2.