
Software Optimization Guide for AMD64 Processors | 25112 Rev. 3.06 September 2005 |
E.1 Half-Register Operations
Optimization
❖Take care when mixing data types of operands within the same register.
Application
This optimization applies to:
•
•
Rationale
Mixing data types in a single register is harmless if only scalar operations are used. However, this practice can cause performance problems if the register is used as a sourcce for a vector operation.
Example 1
Avoid code like this:
addps xmm1, xmm2 | ; Add four | packed | (FPD) values in XMM1 |
| ; to their | corresponding values in | XMM2. |
cvtss2sd xmm1, xmm2 | ; Convert the | ||
;to
;lower
In this example, the second instruction leaves the upper half of XMM1 in FPS format and the lower half in FPD format.
Example 2
Avoid code like this:
addps xmm1,xmm2 | ; Add four | packed | (FPD) values in XMM1 | |
| ; to their | corresponding values in | XMM2. | |
movlpd xmm1,mem64 | ; Move | the | ||
| ; half | of XMM1. |
| |
In this example, The MOVLPD instruction sets the low half of XMM1 to FPD format but leaves the high half unchanged (in FPS format).
356 | SSE and SSE2 Optimizations | Appendix E |