Skip to content

Commit 73f7a27

Browse files
dlrobertsonalexcrichton
authored andcommitted
[x86] sse4.2 add docs for _SIDD_EQUAL_RANGES (rust-lang#107)
- Add docs for the _SIDD_EQUAL_RANGES mode
1 parent b7396c3 commit 73f7a27

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/x86/sse42.rs

+40
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,46 @@ pub unsafe fn _mm_cmpistrm(
171171
/// # }
172172
/// ```
173173
///
174+
/// Find the index of the first character in the haystack that is within a range
175+
/// of characters.
176+
///
177+
/// ```
178+
/// # #![feature(cfg_target_feature)]
179+
/// # #![feature(target_feature)]
180+
/// #
181+
/// # #[macro_use] extern crate stdsimd;
182+
/// #
183+
/// # fn main() {
184+
/// # if cfg_feature_enabled!("sse4.2") {
185+
/// # #[target_feature = "+sse4.2"]
186+
/// # fn worker() {
187+
/// use stdsimd::simd::u8x16;
188+
/// use stdsimd::vendor::{__m128i, _mm_cmpistri, _SIDD_CMP_RANGES};
189+
/// # let b = __m128i::from(u8x16::load(b":;<=>?@[\\]^_`abc", 0));
190+
///
191+
/// // Specify the ranges of values to be searched for [A-Za-z0-9].
192+
/// let a = __m128i::from(u8x16::load(b"AZaz09\0\0\0\0\0\0\0\0\0\0", 0));
193+
///
194+
/// // Use _SIDD_CMP_RANGES to find the index of first byte in ranges.
195+
/// // Which in this case will be the first alpha numeric byte found
196+
/// // in the string.
197+
/// let idx = unsafe {
198+
/// _mm_cmpistri(a, b, _SIDD_CMP_RANGES)
199+
/// };
200+
///
201+
///
202+
/// if idx < 16 {
203+
/// println!("Found an alpha numeric character");
204+
/// # assert_eq!(idx, 13);
205+
/// } else {
206+
/// println!("Did not find an alpha numeric character");
207+
/// }
208+
/// # }
209+
/// # worker();
210+
/// # }
211+
/// # }
212+
/// ```
213+
///
174214
/// Working with 16-bit characters.
175215
///
176216
/// ```

0 commit comments

Comments
 (0)