_mm_permute2_pd
[Note: This document describes a pre-release version of Visual Studio 2010 SP1 and may be revised in any later version.]
Visual Studio 2010 SP1 is required.
Microsoft Specific
Generates the XOP XMM instruction vpermil2pd to select floating-point values from its first two sources, with optional zeroing.
__m128d _mm_permute2_pd (
__m128d src1,
__m128d src2,
__m128i selector,
int control
);
Parameters
[in] src1
A 128-bit parameter that contains two 64-bit floating-point values.[in] src2
A 128-bit parameter that contains two 64-bit floating-point values.[in] selector
A 128-bit parameter that contains two 64-bit integer selector values.[in] control
A 32-bit integer parameter that controls the method of deciding whether to zero values in the result.
Return value
A 128-bit result r that contains two 64-bit floating-point values.
Each value in the result is either zero or a value chosen from the four 64-bit floating-point values in src1 and src2.
Requirements
Intrinsic |
Architecture |
---|---|
_mm_permute2_pd |
XOP |
Header file <intrin.h>
Remarks
Each of the two quadwords in selector selects the value for its corresponding quadword of the result from one of the four 64-bit floating-point values in src1 and src2. This value may be replaced by zero before being written to the result, depending on the value of control and the value of bit 3 of the selector quadword.
For each quadword in selector, the second and third low-order bits select one of the floating-point values in src1 or src2, with values 0 through 1 selecting src1[0] through src1[1] and values 2 through 3 selecting src2[0] through src2[1]. The lowest-order bit of each quadword in selector is ignored.
The next bit of each quadword in selector will be referred to as the "match" bit below. The high-order 60 bits of each quadword in selector are ignored.
The fourth source, control, determines the conditions under which result values will be set to 0. The value of control must be 0, 1, 2, or 3. If control is 0 or 1, the selected floating-point value is written to the destination. If control is 2, then the selected floating-point value is written to the destination if the corresponding match bit in selector is 0, but zero is written if the match bit is 1. If control is 3, then the selected floating-point value is written to the destination if the corresponding match bit is 1, but zero is written if the match bit is 0.
The vpermil2pd instruction is part of the XOP family of instructions. Before you use this intrinsic, you must ensure that the processor supports this instruction. To determine hardware support for this instruction, call the __cpuid intrinsic with InfoType = 0x80000001 and check bit 11 of CPUInfo[2] (ECX). This bit is 1 when the instruction is supported, and 0 otherwise.
Example
#include <stdio.h>
#include <intrin.h>
int main()
{
__m128d a, b, d;
__m128i select;
int i;
a.m128d_f64[0] = 0.;
a.m128d_f64[1] = 1.;
b.m128d_f64[0] = 2.;
b.m128d_f64[1] = 3.;
select.m128i_i64[0] = 2 << 1;
select.m128i_i64[1] = (1 << 1) + 8; // turn on match bit
d = _mm_permute2_pd(a, b, select, 0); // just select, don't zero
printf_s("%.3lf %.3lf\n", d.m128d_f64[0], d.m128d_f64[1]);
d = _mm_permute2_pd(a, b, select, 2); // zero if match is 1
printf_s("%.3lf %.3lf\n", d.m128d_f64[0], d.m128d_f64[1]);
d = _mm_permute2_pd(a, b, select, 3); // zero if match is 0
printf_s("%.3lf %.3lf\n", d.m128d_f64[0], d.m128d_f64[1]);
}
2.000 1.000 2.000 0.000 0.000 1.000
See Also
Reference
XOP Intrinsics Added for Visual Studio 2010 SP1
Change History
Date |
History |
Reason |
---|---|---|
March 2011 |
Added this content. |
SP1 feature change. |