_mm_blendv_ps
Microsoft Specific
Emits the Streaming SIMD Extensions 4 (SSE4) instruction blendvps. This function blends packed single precision floating point values.
__m128 _mm_blendv_ps( __m128 a, __m128 b, __m128 mask );
The return value r and parameters a, b, and mask each consist of 128 bits. r0-r3, a0-a3, b0-b3, and mask0-mask3 are the sequentially ordered 32-bit components of these parameters, where r0, a0, b0, and mask0 indicate the least significant 32 bits.
Before using this intrinsic, software must ensure that the processor supports the instruction.
#include <stdio.h>
#include <smmintrin.h>
int main () {
__m128 a, b, mask;
unsigned __int64 maskValue[4];
maskValue[3] = 0x80000000;
maskValue[2] = 0x80000000;
maskValue[1] = 0x00000000;
maskValue[0] = 0x00000000;
mask.m128_f32[3] = *reinterpret_cast<float *>(&maskValue[3]);
mask.m128_f32[2] = *reinterpret_cast<float *>(&maskValue[2]);
mask.m128_f32[1] = *reinterpret_cast<float *>(&maskValue[1]);
mask.m128_f32[0] = *reinterpret_cast<float *>(&maskValue[0]);
a.m128_f32[3] = -10.25;
a.m128_f32[2] = -20;
a.m128_f32[1] = -900;
a.m128_f32[0] = -32786;
b.m128_f32[3] = 36;
b.m128_f32[2] = 0;
b.m128_f32[1] = 3.25;
b.m128_f32[0] = 78.75;
__m128 res = _mm_blendv_ps( a, b, mask );
printf_s("Original a: %14f %14f %14f %14f\nOriginal b: %14f %14f %14f %14f\n",
a.m128_f32[3], a.m128_f32[2], a.m128_f32[1], a.m128_f32[0],
b.m128_f32[3], b.m128_f32[2], b.m128_f32[1], b.m128_f32[0]);
printf_s("Result res: %14f %14f %14f %14f\n",
res.m128_f32[3], res.m128_f32[2], res.m128_f32[1], res.m128_f32[0]);
return 0;
}