This is supported on x86 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
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::*;
// 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