[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [f-cpu] GCC and jmpz vs. jmpl



> On Wed, Jan 08, 2003 at 03:01:23AM +0100, Yann Guidon wrote:
> [...]
> > Just one question : is GCC bound to this "1/0" scheme ?
>
> AFAIK, gcc expects the result of a compare instruction to be either +1
> or negative (that is, it can use the LSB or the MSB directly). This is
> NOT true for an ordinary `xor'.

or use bitmask of set bits (only MSB and/or LSB works just now).
but I use different way - when I expand == or != I emit
XOR and from that time gcc see it as XOR followed by compare to zero
for remainder of compilation. It allows to do bitwise optimizations like:

if (a == ~b) ...
to emit
 nxor r1,r2,r3
 jmpz r3,...
instead of
 not r2,r2
 xor r1,r2,r3
 jmpz ...
which would be the case if gcc was thinking that xor is compare for
equality and not plain exclusive-or...

devik

*************************************************************
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/