Closed
Description
use core::arch::x86_64::*;
#[target_feature(enable = "sse2")]
pub unsafe fn is_ascii_sse2(a: &[u8; 16]) -> bool {
let a = _mm_loadu_si128(a.as_ptr().cast());
let m = _mm_movemask_epi8(a);
m == 0
}
fn main() {
assert!(cfg!(target_feature = "sse2"));
let s = b"helloworld123456";
assert!(unsafe { is_ascii_sse2(s) });
}
error: Undefined Behavior: each element of a SIMD mask must be all-0-bits or all-1-bits
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs:1381:5
|
1381 | simd_bitmask::<_, u16>(a.as_i8x16()) as u32 as i32
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ each element of a SIMD mask must be all-0-bits or all-1-bits
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::arch::x86_64::_mm_movemask_epi8` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/../../stdarch/crates/core_arch/src/x86/sse2.rs:1381:5
note: inside `is_ascii_sse2` at src/main.rs:6:13
See also:
Metadata
Metadata
Assignees
Labels
No labels