25112 Rev. 3.06 September 2005

Software Optimization Guide for AMD64 Processors

8.4Using XOR to Clear Integer Registers

Optimization

To clear an integer register to all zeros, use the XOR instruction to exclusive OR the register with itself, as shown below.

Rationale

AMD Athlon 64 and AMD Opteron processors are able to avoid the false read dependency on the XOR instruction.

Examples

Acceptable

mov reg, 0

Preferred

xor reg, reg

Chapter 8

Integer Optimizations

169

Page 185
Image 185
AMD 250 manual Using XOR to Clear Integer Registers, Acceptable, 169