-O2 bug in gcc isolated
Norbert Nemec
nobbi@cheerful.com
Sun Oct 1 14:42:00 GMT 2000
Hi there,
a few weeks ago I already reported on this strange bug, now I finally
managed to isolate it.
I'm using gcc 2.95.2 (20000220 Debian GNU/Linux) - I didn't try any
newer, because it is a major task updating the gcc beyond potato on my
system and I need the machine running stable.
In the attachment, you'll find three files. If the .s file you produce
does not show the bug as mine does, the bug obviously does not appear
with the new system.
Although I did not run the tested program, it clearly is wrong (unless
I misunderstand Assembler completely):
In the C-Code, within the while(1) loop, there is a check in the
beginning. Of the two variables, L91_br stays constant, while L21
counts up. L21 is zero at the first time it is compared, at the second
time, it is one and is counted up that way.
In the Assembler code, though, you see the same loop, beginning at .L8
here the order of the two variables is reversed: %ecx stays constant,
%edi counts up. Now consider %edi: it is initialized long before to 0
anyhow: at the second time cmpl is hit, it already is 2 ! (%edx starts
at 1 is incremented once and then put into %edi)
I would really appreciate to hear from you soon. The Sather compiler
(GNU Sather project) creates code like that all the time and we have
already spend hours tracking bugs before we realized that gcc was
messing it up. Using -O instead of -O2 does help, but as you can see,
optimization really does make a difference on our code... (Never
thought that constant folding might make such an effect !!!)
Ciao,
Nobbi
--
-- ______________________________________________________
-- JESUS CHRIST IS LORD!
-- To Him, even that machine here has to obey...
--
-- _________________________________Norbert "Nobbi" Nemec
-- Hindenburgstr. 44 ... D-91054 Erlangen ... Germany
-- eMail: <nobbi@cheerful.com> Tel: +49-(0)-9131-204180
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-O2-bug.tgz
Type: application/x-gzip
Size: 1363 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/20001001/d8cc3c85/attachment.bin>
More information about the Gcc-bugs
mailing list