_mm_cmpestri in core::arch::x86_64 - Rust
Description: Compares packed strings `a` and `b` with lengths `la` and `lb` using the control in `IMM8` and return the generated index. Similar to `_mm_cmpistri` with the exception that `_mm_cmpistri` implicitly determines the length of `a` and `b`.
Keywords: rust, rustlang, rust-lang, _mm_cmpestri

# Function core::arch::x86_64::_mm_cmpestri
1.27.0[−][src]

    pub unsafe fn _mm_cmpestri<const IMM8: i32>(
        a: __m128i,
        la: i32,
        b: __m128i,
        lb: i32
    ) -> i32

This is supported on x86-64 and target feature `sse4.2` only.
Expand description

Compares packed strings `a` and `b` with lengths `la` and `lb` using the control in `IMM8` and return the generated index. Similar to `_mm_cmpistri` with the exception that `_mm_cmpistri` implicitly determines the length of `a` and `b`.

# Control modes

The control specified by `IMM8` may be one or more of the following.

## Data size and signedness

- `_SIDD_UBYTE_OPS` - Default
- `_SIDD_UWORD_OPS`
- `_SIDD_SBYTE_OPS`
- `_SIDD_SWORD_OPS`

## Comparison options

- `_SIDD_CMP_EQUAL_ANY` - Default
- `_SIDD_CMP_RANGES`
- `_SIDD_CMP_EQUAL_EACH`
- `_SIDD_CMP_EQUAL_ORDERED`

## Result polarity

- `_SIDD_POSITIVE_POLARITY` - Default
- `_SIDD_NEGATIVE_POLARITY`

## Bit returned

- `_SIDD_LEAST_SIGNIFICANT` - Default
- `_SIDD_MOST_SIGNIFICANT`

# Examples

    #[cfg(target_arch = "x86")]
    use std::arch::x86::*;
    #[cfg(target_arch = "x86_64")]
    use std::arch::x86_64::*;

    // The string we want to find a substring in
    let haystack = b"Split \r\n\t line  ";

    // The string we want to search for with some
    // extra bytes we do not want to search for.
    let needle = b"\r\n\t ignore this ";

    let a = _mm_loadu_si128(needle.as_ptr() as *const _);
    let b = _mm_loadu_si128(haystack.as_ptr() as *const _);

    // Note: We explicitly specify we only want to search `b` for the
    // first 3 characters of a.
    let idx = _mm_cmpestri(a, 3, b, 15, _SIDD_CMP_EQUAL_ORDERED);

    assert_eq!(idx, 6);

Run

Intel’s documentation