Bug in TC2.0 Optimization

Nico de Vries nevries at cs.ruu.nl
Fri May 3 20:40:59 AEST 1991


In <1991Apr28.220249.1 at cc.helsinki.fi> wirzenius at cc.helsinki.fi writes:

>In article <1991Apr22.130418.8079 at uni-paderborn.de>, higgins at uni-paderborn.de (Frank Westheider) writes:
>>     Input[func(bla)+bla] = !Input[func(bla)+bla]
>
>A side note: do you really want to call func(bla) twice?
>
>> In Assembly-Mode there will be
>>     xor dx,dx
>> generated, but dx has never been loaded !
>
>I'm not familiar with assembler, but if this does what I think it does,
>i.e. xors dx with itself and puts the result back into dx, then it
>doesn't matter whether dx has been loaded or not. The truth table for
>xor is:
>
>	a	b	a xor b
>
>	0	0	0
>	0	1	1
>	1	0	1
>	1	1	0
>
>Since the result is 1 if and only if the operands are different, xoring
>a value with itself is identical to 0, regardless of the value of the
>operand. So the assembler statement sets dx to 0. Why didn't they just
>do it explicitly? Maybe this method is faster, smaller, or has some
>other virtue.
>
>Lars Wirzenius    wirzenius at cc.helsinki.fi
On 8086 and 80286 processors xor dx,dx is in most cases faster than
mov dx, 0h. On 80386 and i486 there is no reel reason to do this any more
by the way.



More information about the Comp.lang.c mailing list