mov reg,0 vs xor reg,reg in core.atomic ?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Apr 10 22:45:17 PDT 2016


On 04/10/2016 04:00 AM, darat wrote:
> Is there a particular reason explaining why mov reg,0 is used and not
> xor reg,reg ?
> (or even and reg, 0)
>
> for example here:
>
> https://github.com/D-Programming-Language/druntime/blob/master/src/core/atomic.d#L1009
>
>
> It seems that in Go too mov is used:
> https://github.com/golang/go/blob/0104a31b8fbcbe52728a08867b26415d282c35d2/src/runtime/internal/atomic/asm_amd64p32.s#L15
>
>
>
>

I don't know the answer but Google finds interesting discussions about that:

 
https://www.google.com/search?q=mov+0+versus+xor+cycles&ie=utf-8&oe=utf-8#q=mov+0+versus+xor+cpu+cycle

Ali



More information about the Digitalmars-d-learn mailing list