Function _mm_cmpestri

#[target_feature(enable = "sse4.2")]
pub fn _mm_cmpestri(a: __m128i, la: i32, b: __m128i, lb: i32, IMM8: i32) -> i32

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

Comparison options

Result polarity

Bit returned

Examples

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

# fn main() {
#     if is_x86_feature_detected!("sse4.2") {
#         #[target_feature(enable = "sse4.2")]
#         unsafe fn worker() {

// 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 = unsafe { _mm_loadu_si128(needle.as_ptr() as *const _) };
let b = unsafe { _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);
#         }
#         unsafe { worker(); }
#     }
# }

Intel's documentation