_mm256_permute2_ps, _mm_permute2_ps

Permutes two float32 values into a destination vector. The corresponding Intel® AVX instruction is VPERMIL2PS.

Syntax

extern __m256 __cdecl _mm256_permute2_ps(__m256 a, __m256 b, __m256i ctrl, int imm);

extern __m128 __cdecl _mm_permute2_ps(__m128 a, __m128 b, __m128i ctrl, int imm);

Arguments

a

a 256-bit or 128-bit float32 source vector

b

a 256-bit or 128-bit float32 source vector

ctrl

float32 vector used for the operation

A vector with

  • 2-bit source_select fields, one for each corresponding element of the source vectors
  • a match bit

The zero_match field of the imm argument and the match bit of ctrl vector determine the value that is written to the corresponding data element in the destination vector.

imm

an immediate byte that specifies a 2-bit zero_match control field

Description

Permutes two single-precision floating-point (float32) values. The intrinsic selects one float32 value from one pair (from 128-bit source) or two pairs (from 256-bit source) of float32 values in the source vectors, a and b. The selection is based on the source select field specified in the third vector, ctrl.

Each selected float32 value is either copied or substituted with zero in the destination vector depending on the respective match bit in the ctrl vector and the zero_match control field specified by the imm parameter.

Returns

A 256-bit or 128-bit float32 vector with permuted values.