This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Buggy peephole prevents bootstrap (i386)
- To: Zack Weinberg <zackw at stanford dot edu>
- Subject: Re: Buggy peephole prevents bootstrap (i386)
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Sat, 14 Oct 2000 14:13:03 +1100 (EST)
- cc: gcc-bugs at gcc dot gnu dot org, Jan Hubicka <jh at suse dot cz>
On Fri, 13 Oct 2000, Zack Weinberg wrote:
> This transformation was done to save space - the add instruction is
> three bytes shorter than the corresponding compare. However, add
> doesn't set the condition codes the same way cmp and sub do. It
> appears (from staring at the confusing Intel reference manual) that
> add's condition codes are usable only with the signed conditional
Actually, it's the other way around. You can replace
cmp $val,%reg
j<cc> ; cc is one of a,b,ae,be or their aliases
with
add $-val,%reg
jn<cc>
only for _unsigned_ comparisons (and val != 0). Signed comparisons get
the overflow bit wrong. If you don't believe me, run a few cases through
a debugger - I had to do so to make sure I was correct. ;-)
Regards, Alan Modra
--
Linuxcare. Support for the Revolution.