Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 7/13/2023
Public
Document Table of Contents

Details About Intrinsics for Half Floats

There are four intrinsics for converting half-floats to 32-bit floats and 32-bit floats to half-floats. The prototypes for these half-float conversion intrinsics are in the emmintrin.h file.

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

#include <immintrin.h>

float _cvtsh_ss(unsigned short x);

This intrinsic takes a half-float value, x, and converts it to a 32-bit float value, which is returned.

unsigned short _cvtss_sh(float x, int imm);

This intrinsic takes a 32-bit float value, x, and converts it to a half-float value, which is returned.

__m128 _mm_cvtph_ps(__m128i x);

This intrinsic takes four packed half-float values and converts them to four 32-bit float values, which are returned. The upper 64-bits of x are ignored. The lower 64-bits are taken as four 16-bit float values for conversion.

__m128i _mm_cvtps_ph(_m128 x, int imm);

This intrinsic takes four packed 32-bit float values and converts them to four half-float values, which are returned. The upper 64-bits in the returned result are all zeros. The lower 64-bits contain the four packed 16-bit float values.