
Software Optimization Guide for AMD64 Processors | 25112 Rev. 3.06 September 2005 |
E.8 Data Conversion
Optimization
Use care when selecting instructions to convert values from one type to another.
Application
This optimization applies to:
•
•
Rationale
For example, the CVTDQ2PS instruction converts four packed
Table 22 shows the recommendations for
Table 22. Converting Scalar Values
Source | Destination format | Preferred instructions | Notes | |
format | ||||
|
|
| ||
|
|
|
| |
FPS | INT XMM | cvtps2dq xmm1, xmm2 |
| |
|
|
|
| |
FPS | INT GPR | cvtss2si reg32/64, xmm1 |
| |
|
|
|
| |
FPS | FPD | cvtss2sd xmm1, xmm2 |
| |
|
|
|
| |
FPD | INT XMM | unpcklpd xmm2, xmm2 | UNPCKLPD ensures that the high | |
|
| cvtpd2dq xmm1, xmm2 | half of XMM2 is also in FPD | |
|
|
| format. | |
|
|
|
| |
FPD | INT GPR | cvtsd2si reg32/64, xmm1 |
| |
|
|
|
| |
FPD | FPS | xorps xmm1, xmm1 | XORPS ensures that the high half | |
|
| cvtsd2ss xmm1, xmm2 | of XMM1 is in FPS format in case | |
|
|
| a MOVAPS instruction is used | |
|
|
| later. | |
|
|
|
| |
INT XMM | FPS | cvtdq2ps xmm1, xmm2 |
| |
|
|
|
| |
INT XMM | FPD | cvtdq2pd xmm1, xmm2 |
| |
|
|
|
|
364 | SSE and SSE2 Optimizations | Appendix E |