_mm_cmpestri
Microsoft Specific
Emits the Streaming SIMD Extensions 4 (SSE4) instruction pcmpestri. This instruction compares two parameters.
int _mm_cmpestri (
__m128i a,
int la,
__m128i b,
int lb,
const int mode
);
Parameters
Parameter |
Description |
[in] a |
A string fragment with a maximum size of 16 byte characters or 8 word characters. |
[in] la |
An integer that specifies the size of the string in a. |
[in] b |
A string fragment with a maximum size of 16 byte characters or 8 word characters. |
[in] lb |
An integer that specifies the size of the string in b. |
[in] mode |
A constant that indicates whether characters are bytes or words, the type of comparison to do, and the format of the returned value. |
Return value
An integer that ranges between 0 and MaxSize. Maxsize is returned when the resulting bitmask is equal to 0. Otherwise, the index of either the leftmost or rightmost bit set to 1 in this mask. The input parameter mode determines whether to return the leftmost or rightmost bit.
The pcmpestri instruction computes the bitmask where bit0, bit1, bit2… in the mask correspond to the result of the operation on a0, a1, a2… in a.
Requirements
Intrinsic |
Architecture |
_mm_cmpestri |
x86, x64 |
Header file <nmmintrin.h>
Remarks
b0, b1, b2… indicate the first, second, third… characters in b. b0 is stored in the least significant bits of b. The same notation applies to a. MaxSize is either 16 for byte characters or 8 for word characters. MaxSize is the maximum number of characters that fit into a __m128i data type. The lower 7 bits in mode determine the type of the input characters, the comparison to run, and the format of the return value. They are described in the following table:
mode in binary |
Defined constant |
Description |
xxxxxx00 |
_SIDD_UBYTE_OPS |
a and b contain strings of unsigned 8-bit characters. |
xxxxxx01 |
_SIDD_UWORD_OPS |
a and b contain strings of unsigned 16-bit characters. |
xxxxxx10 |
_SIDD_SBYTE_OPS |
a and b contain strings of signed 8-bit characters. |
xxxxxx11 |
_SIDD_SWORD_OPS |
a and b contain strings of signed 16-bit characters. |
xxxx00xx |
_SIDD_CMP_EQUAL_ANY |
Find if equal any mode: For each character c in a, determine whether any character in b is equal to c. |
xxxx01xx |
_SIDD_CMP_RANGES |
Find in ranges mode: For each character c in a, determine whether b0 <= c <= b1or b2 <= c <= b3… |
xxxx10xx |
_SIDD_CMP_EQUAL_EACH |
Find if equal each mode: This implements the string equality algorithm. |
xxxx11xx |
_SIDD_CMP_EQUAL_ORDERED |
Find if equal ordered mode: This implements the substring search algorithm. |
xxx0xxxx |
_SIDD_POSITIVE_POLARITY |
No effect. |
xx01xxxx |
_SIDD_NEGATIVE_POLARITY |
Negation of resulting bitmask. |
xx11xxxx |
_SIDD_MASKED_NEGATIVE_POLARITY |
Negation of resulting bitmask except for bits that have an index larger than the size of a or b (see details of pcmpestri instruction). |
x0xxxxxx |
_SIDD_LEAST_SIGNIFICANT |
The index of the rightmost bit set to 1 is returned. |
x1xxxxxx |
_SIDD_MOST_SIGNIFICANT |
The index of the leftmost bit set to 1 is returned. |
Before using this intrinsic, software must ensure that the processor supports the instruction.
Example
See the example for _mm_cmpestra.
See Also
Reference
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Revised the constant names. |
Content bug fix. |