Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Conversion Intrinsics

Intel® Streaming SIMD Extensions 2 (Intel® SSE2) intrinsics for floating-point conversion operations are listed in this topic. The prototypes for Intel® SSE2 intrinsics are in the emmintrin.h header file.

To use these intrinsics, include the immintrin.h file as follows:

#include <immintrin.h>

Each conversion intrinsic takes one data type and performs a conversion to a different type. Some conversions, such as those performed by the _mm_cvtpd_ps intrinsic, result in a loss of precision. The rounding mode used in such cases is determined by the value in the MXCSR register. The default rounding mode is round-to-nearest.

NOTE:

The rounding mode used by the C and C++ languages when performing a type conversion is to truncate. The _mm_cvttpd_epi32 and _mm_cvttsd_si32 intrinsics use the truncate rounding mode regardless of the mode specified by the MXCSR register.

The results of each intrinsic operation are placed in a register. The information about what is placed in each register appears in the tables below, in the detailed explanation for each intrinsic. For each intrinsic, the resulting register is represented by R, R0, R1, R2, and R3, where each represent the registers in which results are placed.

Intrinsic Name

Operation

Corresponding
Intel® SSE2 Instruction

_mm_cvtpd_ps

Convert DP FP to SP FP

CVTPD2PS

_mm_cvtps_pd

Convert from SP FP to DP FP

CVTPS2PD

_mm_cvtepi32_pd

Convert lower integer values to DP FP

CVTDQ2PD

_mm_cvtpd_epi32

Convert DP FP values to integer values

CVTPD2DQ

_mm_cvtsd_si32

Convert lower DP FP value to integer value

CVTSD2SI

_mm_cvtsd_ss

Convert lower DP FP value to SP FP

CVTSD2SS

_mm_cvtsi32_sd

Convert signed integer value to DP FP

CVTSI2SD

_mm_cvtss_sd

Convert lower SP FP value to DP FP

CVTSS2SD

_mm_cvttpd_epi32

Convert DP FP values to signed integers

CVTTPD2DQ

_mm_cvttsd_si32

Convert lower DP FP to signed integer

CVTTSD2SI

_mm_cvtpd_pi32

Convert two DP FP values to signed integer values

CVTPD2PI

_mm_cvttpd_pi32

Convert two DP FP values to signed integer values using truncate

CVTTPD2PI

_mm_cvtpi32_pd

Convert two signed integer values to DP FP

CVTPI2PD

_mm_cvtsd_f64

Extract DP FP value from first vector element

None

_mm_cvtpd_ps

__m128 _mm_cvtpd_ps(__m128d a);

Converts the two DP FP values of a to SP FP values.

R0

R1

R2

R3

(float) a0

(float) a1

0.0

0.0

_mm_cvtps_pd

__m128d _mm_cvtps_pd(__m128 a);

Converts the lower two SP FP values of a to DP FP values.

R0

R1

(double) a0

(double) a1

_mm_cvtepi32_pd

__m128d _mm_cvtepi32_pd(__m128i a);

Converts the lower two signed 32-bit integer values of a to DP FP values.

R0

R1

(double) a0

(double) a1

_mm_cvtpd_epi32

__m128i _mm_cvtpd_epi32(__m128d a);

Converts the two DP FP values of a to 32-bit signed integer values.

R0

R1

R2

R3

(int) a0

(int) a1

0x0

0x0

_mm_cvtsd_si32

int _mm_cvtsd_si32(__m128d a);

Converts the lower DP FP value of a to a 32-bit signed integer value.

R

(int) a0

_mm_cvtsd_ss

__m128 _mm_cvtsd_ss(__m128 a, __m128d b);

Converts the lower DP FP value of b to an SP FP value. The upper SP FP values in a are passed through.

R0

R1

R2

R3

(float) b0

a1

a2

a3

_mm_cvtsi32_sd

__m128d _mm_cvtsi32_sd(__m128d a, int b);

Converts the signed integer value in b to a DP FP value. The upper DP FP value in a is passed through.

R0

R1

(double) b

a1

_mm_cvtss_sd

__m128d _mm_cvtss_sd(__m128d a, __m128 b);

Converts the lower SP FP value of b to a DP FP value. The upper value DP FP value in a is passed through.

R0

R1

(double) b0

a1

_mm_cvttpd_epi32

__m128i _mm_cvttpd_epi32(__m128d a);

Converts the two DP FP values of a to 32-bit signed integers using truncate.

R0

R1

R2

R3

(int) a0

(int) a1

0x0

0x0

_mm_cvttsd_si32

int _mm_cvttsd_si32(__m128d a);

Converts the lower DP FP value of a to a 32-bit signed integer using truncate.

R

(int) a0

_mm_cvtpd_pi32

__m64 _mm_cvtpd_pi32(__m128d a);

Converts the two DP FP values of a to 32-bit signed integer values.

R0

R1

(int)a0

(int) a1

_mm_cvttpd_pi32

__m64 _mm_cvttpd_pi32(__m128d a);

Converts the two DP FP values of a to 32-bit signed integer values using truncate.

R0

R1

(int)a0

(int) a1

_mm_cvtpi32_pd

__m128d _mm_cvtpi32_pd(__m64 a);

Converts the two 32-bit signed integer values of a to DP FP values.

R0

R1

(double)a0

(double)a1

_mm_cvtsd_f64

double _mm_cvtsd_f64(__m128d a);

This intrinsic extracts a double precision floating point value from the first vector element of an __m128d. It does so in the most efficient manner possible in the context used.

NOTE:

This intrinsic does not map to any specific Intel® SSE2 instruction.