This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC-generated code and i386 condition codes behavior
- From: Robert Dewar <dewar at adacore dot com>
- To: Bryan Ford <baford at mit dot edu>
- Cc: Richard Henderson <rth at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Fri, 04 Nov 2005 12:27:06 -0500
- Subject: Re: GCC-generated code and i386 condition codes behavior
- References: <28932467.1130186393749.JavaMail.root@vms076.mailsrvcs.net> <20051025223019.GC16782@redhat.com> <200511041215.10326.baford@mit.edu>
My question: does GCC-generated code ever actually depend on this aspect
of the x86 architecture - i.e., on instructions that architecturally
change some but not all condition codes _not_ changing those bits that
they're not supposed to change?
No.
An interesting anecdote from decades ago. When we were working on
the Realia COBOL compiler, and distributing it for the PC, we got
a mysterious message from IBM saying that they had a problem but
could not tell us what it was unless we signed a NDA. We signed,
and it turned out that the CMOS chip (from Harris?) 80C88 used
in the ancient IBM convertible machine had a bug, CVD destroyed
the carry flag, and Realia COBOL was the ONLY software that
was affected. We made a change to the compiler, told no one
(a requirement of the NDA), and everyone was happy :-) although
the generated code was (and probably still is) less efficient :-)
I must say I am a bit surprised that gcc never takes advantage
of the fact that inc and dec do not destroy the carry flag, this
is quite significant for some loops.