_mm_blend_ps
Microsoft Specific
Emits the Streaming SIMD Extensions 4 (SSE4) instruction blendps. This instruction blends packed single precision floating point values.
__m128 _mm_blend_ps( __m128 a, __m128 b, const int mask );
The return value r and parameters a and b each consist of 128 bits. r0-r3, a0-a3, and b0-b3 are the sequentially ordered 32-bit components of these parameters, where r0, a0, and b0 indicate the least significant 32 bits.
mask0 - 3 are the four least significant bits of parameter mask.
Before using this intrinsic, software must ensure that the processor supports the instruction.
#include <stdio.h>
#include <smmintrin.h>
int main () {
__m128 a, b;
const int mask = 12;
a.m128_u32[3] = 0xFFEEDDCC;
a.m128_u32[2] = 0xBBAA9988;
a.m128_u32[1] = 0x77665544;
a.m128_u32[0] = 0x33221100;
b.m128_u32[3] = 0x11112222;
b.m128_u32[2] = 0x33334444;
b.m128_u32[1] = 0x55556666;
b.m128_u32[0] = 0x77778888;
__m128 res = _mm_blend_ps( a, b, mask );
printf_s("Original a: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
a.m128_u32[3], a.m128_u32[2], a.m128_u32[1], a.m128_u32[0]);
printf_s("Original b: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
b.m128_u32[3], b.m128_u32[2], b.m128_u32[1], b.m128_u32[0]);
printf_s("Result res: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
res.m128_u32[3], res.m128_u32[2],
res.m128_u32[1], res.m128_u32[0]);
return 0;
}
Original a: 0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100 Original b: 0x11112222, 0x33334444, 0x55556666, 0x77778888 Result res: 0x11112222, 0x33334444, 0x77665544, 0x33221100