25112 Rev. 3.06 September 2005

Software Optimization Guide for AMD64 Processors

E.2 Zeroing Out an XMM Register

Optimization

When it is necessary to zero out an XMM register, use an instruction whose format matches the format required by the consumers of the zeroed register.

Application

This optimization applies to:

32-bit software

64-bit software

Rationale

When an XMM register must be set to zero, using the appropriate instruction helps reduce the chance of any performance penalty later.

Table 21 shows the different possible consumers of an XMM register and the corresponding instruction that should be used to zero out the register.

Table 21. Clearing XMM Registers

Producer of Zero

Example Consumers of Zero

 

 

xorpd xmm1, xmm1

cmppd xmm1, xmm2

 

 

 

cmpsd xmm1, xmm2

 

 

 

comisd xmm1, xmm2

 

 

 

maxpd xmm1, xmm2

 

 

 

maxsd xmm1, xmm2

 

 

 

ucomisd xmm1, xmm2

 

 

 

subsd xmm1, xmm2

 

 

xorps xmm1, xmm1

cmpps xmm1, xmm2

 

 

 

cmpss xmm1, xmm2

 

 

 

comiss xmm1, xmm2

 

 

 

maxps xmm1, xmm2

 

 

 

maxss xmm1, xmm2

 

 

 

ucomiss xmm1, xmm2

 

 

 

subss xmm1, xmm2

 

 

Appendix E

SSE and SSE2 Optimizations

357

Page 373
Image 373
AMD 250 manual Zeroing Out an XMM Register, Clearing XMM Registers, 357