This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Buggy peephole prevents bootstrap (i386)


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.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]