BLENDPD: Blend Packed Double-Precision Floating-Point Values

For information about interpreting this page, see the help page.
Opcode and MnemonicEncoding16 bit Mode32 bit Mode64 bit ModeCPUID Feature FlagDescription
66 0F 3A 0D /r ib
BLENDPD xmm1, xmm2/m128, imm8
LEGACYInvalidValidValidSSE4_1Selects packed double-precision floating-point values from xmm1 and xmm2/m128 from a mask specified in imm8. Stores the result in xmm1.
VEX.128.66.0F3A.WIG 0D /r ib
VBLENDPD xmm1, xmm2, xmm3/m128, imm8
VEXInvalidValidValidAVXSelects packed double-precision floating-point values from xmm2 and xmm3/m128 from a mask specified in imm8. Stores the result in xmm1.
VEX.256.66.0F3A.WIG 0D /r ib
VBLENDPD ymm1, ymm2, ymm3/m256, imm8
VEXInvalidValidValidAVXSelects packed double-precision floating-point values from ymm2 and ymm3/m256 from a mask specified in imm8. Stores the result in ymm1.

Encoding

EncodingOperand 1Operand 2Operand 3Operand 4
LEGACYModRM.reg[rw]ModRM.r/m[r]imm8[1:0]
VEXModRM.reg[w]VEX.vvvv[r]ModRM.r/m[r]imm8[3:0]

Description

The (V)BLENDPD instruction conditionally moves double-precision floating-point values from the second source operand into the first source operand. The result is stored in the destination operand.

This instruction, despite being named as if it operates on floating-point numbers, will work on 64 bit integers as well.

All versions except the legacy SSE version zero the unused upper SIMD register bits.

Operation

This pseudo-code uses C# syntax. A list of the types used is available here.
public void BLENDPD(SimdF64 dest, SimdF64 src, byte mask)
{
  // If `mask[n]` is 0, `dest` will be copied into itself (i.e. nothing will happen)
  if (mask[0])
    dest[0] = src[0];
  if (mask[1])
    dest[1] = src[1];
  // dest[2..Simd.MAX] (unmodified)
}

void VBLENDPD_Vex(SimdF64 dest, SimdF64 src1, SimdF64 src2, byte mask, int kl)
{
  for (int n = 0; n < kl, n++) {
    if (mask[n])
      dest[n] = src2[n];
    else
      dest[n] = src1[n];
  }
  dest[kl..Simd.MAX] = 0;
}
public void VBLENDPD_Vex128(SimdF64 dest, SimdF64 src1, SimdF64 src2, byte mask)
{
  VBLENDPD_Vex(dest, src1, src2, mask, 2);
}
public void VBLENDPD_Vex256(SimdF64 dest, SimdF64 src1, SimdF64 src2, byte mask)
{
  VBLENDPD_Vex(dest, src1, src2, mask, 4);
}

C Intrinsics

Exceptions

SIMD Floating-Point

None

Other

See Exceptions Type 4.