Intel® C++ Compiler 16.0 User and Reference Guide
This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).
The cast intrinsics are used to satisfy strong type checking. They allow conversion from one type to another with no change in value.
Consider the mm512 sllv epi32 intrinsic that takes two int32 vectors and performs a bitwise left shift on the first parameter. The prototype for the intrinsic is as follows:
extern __m512i __cdecl _mm512_sllv_epi32(_m512i v2,_m512i v3);
Assume that you have a float32 vector and you want to do a bitwise left shift of each element. You cannot pass the _m512 (float32) data type to the intrinsic because the compiler will generate a type mismatch error.
_m512i shift; _m512 fvec1, fvec2; fvec2 = _mm512_sllv_epi32(fvec1, shift); // type mismatch - first parameter is required to be _m512
Now consider using one of the cast intrinsics as follows:
_m512i shift; _m512 fvec1, fvec2 ; fvec2 = _mm512_castsi512_ps(_mm512_sllv_epi32(_mm512_castpd_si512(fvec1), shift));where _mm512_castps_si512(fvec1) assigns the float32 vector, int32 vector so that it can be processed by the _mm512_sllv_epi32 intrinsic, and _mm512_castsi512_ps assigns the result of the _mm512_sllv_epi32 from an int32 vector to a float32 vector, fvec2.
The cast intrinsics, therefore, allow you to use existing data types for all possible data types.