Does using xor reg, reg give advantage over mov reg, 0? [duplicate]

an actual answer for you:

Intel 64 and IA-32 Architectures Optimization Reference Manual

Section 3.5.1.7 is where you want to look.

In short there are situations where an xor or a mov may be preferred. The issues center around dependency chains and preservation of condition codes.

In processors based on Intel Core microarchitecture, a number of instructions can help clear execution
dependency when software uses these instruction to clear register content to zero.

In contexts where the condition codes must be preserved, move 0 into
the register instead.

Leave a Comment