_mm_com_epi16
[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 instruction vpcomw to return a bitmask generated by a word-by-word signed comparison of its first two sources using the condition given by the third source.
__m128i _mm_com_epi16 (
__m128i src1,
__m128i src2,
int condition
);
Parameters
[in] src1
Packed 128-bit array of eight 16-bit signed integers.[in] src2
Packed 128-bit array of eight 16-bit signed integers.[in] condition
A 32-bit integer condition to be used in the comparison. Legal values are 0 through 7.
Return value
A packed 128-bit array r of eight 16-bit unsigned integers, each of which is either 0x0000 or 0xFFFF. If cond is the logical operator implied by the value of condition, then
r[i] := src1[i] cond src2[i] ? 0xFFFF : 0x0000;
Requirements
Intrinsic |
Architecture |
---|---|
_mm_com_epi16 |
XOP |
Header file <intrin.h>
Remarks
This instruction compares each byte of src1 to the corresponding byte of src2, using the comparison operator described by condition. (Each pair of bytes uses the same comparison operator.) The legal values condition are 0 through 7. By including <intrin.h> you will be able to use the following names rather than numerical values for condition:
Integer Value |
Symbolic Name |
Meaning |
---|---|---|
0 |
_MM_PCOMCTRL_LT |
r[i] = (src1[i] < src2[i]) ? 0xFFFF : 0x0000 |
1 |
_MM_PCOMCTRL_LE |
r[i] = (src1[i] <= src2[i]) ? 0xFFFF : 0x0000 |
2 |
_MM_PCOMCTRL_GT |
r[i] = (src1[i] > src2[i]) ? 0xFFFF : 0x0000 |
3 |
_MM_PCOMCTRL_GE |
r[i] = (src1[i] >= src2[i]) ? 0xFFFF : 0x0000 |
4 |
_MM_PCOMCTRL_EQ |
r[i] = (src1[i] == src2[i]) ? 0xFFFF : 0x0000 |
5 |
_MM_PCOMCTRL_NEQ |
r[i] = (src1[i] != src2[i]) ? 0xFFFF : 0x0000 |
6 |
_MM_PCOMCTRL_FALSE |
r[i] = 0x0000 (mask of all zeros) |
7 |
_MM_PCOMCTRL_TRUE |
r[i] = 0xFFFF (mask of all ones) |
If you prefer, you may use the following macros, which will be defined when <intrin.h> is included:
Macro |
Meaning |
---|---|
_mm_comlt_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 0) |
_mm_comle_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 1) |
_mm_comgt_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 2) |
_mm_comge_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 3) |
_mm_comeq_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 4) |
_mm_comneq_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 5) |
_mm_comfalse_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 6) |
_mm_comtrue_epi16(src1, src2) |
_mm_com_epi16(src1, src2, 7) |
The vpcomb 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>
main()
{
__m128i a, b, d;
int i;
for (i = 0; i < 8; i++) {
a.m128i_i16[i] = ((20011*i) % 65535) - 32768;
b.m128i_i16[i] = ((32767*i) % 65535) - 32768;
}
printf("src1: ");
for (i = 0; i < 8; i++) printf_s(" %6d", a.m128i_i16[i]);
printf_s("\nsrc2: ");
for (i = 0; i < 8; i++) printf_s(" %6d", b.m128i_i16[i]);
printf_s("\n< mask:");
d = _mm_com_epi16(a, b, _MM_PCOMCTRL_LT);
for (i = 0; i < 8; i++) printf_s(" %04x", d.m128i_u16[i]);
printf_s("\n== mask:");
d = _mm_com_epi16(a, b, _MM_PCOMCTRL_EQ);
for (i = 0; i < 8; i++) printf_s(" %04x", d.m128i_u16[i]);
printf("\n");
}
src1: -32768 -12757 7254 27265 -18259 1752 21763 -23761 src2: -32768 -1 32766 -2 32765 -3 32764 -4 < mask: 0000 ffff ffff 0000 ffff 0000 ffff ffff == mask: ffff 0000 0000 0000 0000 0000 0000 0000
See Also
Reference
XOP Intrinsics Added for Visual Studio 2010 SP1
Change History
Date |
History |
Reason |
---|---|---|
March 2011 |
Added this content. |
SP1 feature change. |