Visual Studio 2010

Visual Studio 2010 SP1 is required.

Microsoft Specific

Generates the XOP instruction vpcomuq to return a bitmask generated by a quadword-by-quadword unsigned comparison of its first two sources using the condition given by the third source.

__m128i _mm_com_epu64 (
   __m128i src1,
   __m128i src2,
   int condition

[in] src1

Packed 128-bit array of two 64-bit unsigned integers.

[in] src2

Packed 128-bit array of two 64-bit unsigned integers.

[in] condition

A 32-bit integer condition to be used in the comparison. Legal values are 0 through 7.

A packed 128-bit array r of two 64-bit unsigned integers, each of which is either 0x0000000000000000 or 0xFFFFFFFFFFFFFFFF. If cond is the logical operator implied by the value of condition, then

r[i] := src1[i] cond src2[i] ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000;





Header file <intrin.h>

This instruction compares each quadword of src1 to the corresponding quadword of src2, using the comparison operator described by condition. (Each pair of quadwords 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




r[i] = (src1[i] < src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = (src1[i] <= src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = (src1[i] > src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = (src1[i] >= src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = (src1[i] == src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = (src1[i] != src2[i]) ? 0xFFFFFFFFFFFFFFFF : 0x0000000000000000



r[i] = 0x0000000000000000 (mask of all zeros)



r[i] = 0xFFFFFFFFFFFFFFFF (mask of all ones)

If you prefer, you may use the following macros, which will be defined when <intrin.h> is included:



_mm_comlt_epu64(src1, src2)

_mm_com_epu64(src1, src2, 0)

_mm_comle_epu64(src1, src2)

_mm_com_epu64(src1, src2, 1)

_mm_comgt_epu64(src1, src2)

_mm_com_epu64(src1, src2, 2)

_mm_comge_epu64(src1, src2)

_mm_com_epu64(src1, src2, 3)

_mm_comeq_epu64(src1, src2)

_mm_com_epu64(src1, src2, 4)

_mm_comneq_epu64(src1, src2)

_mm_com_epu64(src1, src2, 5)

_mm_comfalse_epu64(src1, src2)

_mm_com_epu64(src1, src2, 6)

_mm_comtrue_epu64(src1, src2)

_mm_com_epu64(src1, src2, 7)

The vpcomuq 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.

#include <stdio.h>
#include <intrin.h>
    __m128i a, b, d;
    int i;
    a.m128i_i64[0] = -10;
    a.m128i_i64[1] =  10;
    b.m128i_i64[0] =  22;
    b.m128i_i64[1] = -22;
    printf("src1:     %20I64u %20I64u\n",
            a.m128i_u64[0], a.m128i_u64[1]);
    printf("src2:     %20I64u %20I64u\n",
            b.m128i_u64[0], b.m128i_u64[1]);
    d = _mm_com_epu64(a, b, _MM_PCOMCTRL_LT);
    printf("< mask:       %016I64x     %016I64x\n",
            d.m128i_u64[0], d.m128i_u64[1]);
    d = _mm_com_epu64(a, b, _MM_PCOMCTRL_GT);
    printf("> mask:       %016I64x     %016I64x\n",
            d.m128i_u64[0], d.m128i_u64[1]);
src1:     18446744073709551606                   10
src2:                       22 18446744073709551594
< mask:       0000000000000000     ffffffffffffffff
> mask:       ffffffffffffffff     0000000000000000

Community Additions