diff options
| author | Jubilee Young <workingjubilee@gmail.com> | 2023-12-13 17:46:46 -0800 |
|---|---|---|
| committer | Jubilee Young <workingjubilee@gmail.com> | 2023-12-13 17:46:49 -0800 |
| commit | b6eeb4ee90e31f7846e94e4f639f44bc5f623ca0 (patch) | |
| tree | c4f6d62271be99a21ca622c8be8cd07b3457fb22 | |
| parent | 1273da658ea64245e18466e50d59daa2cc49822e (diff) | |
| download | rust-b6eeb4ee90e31f7846e94e4f639f44bc5f623ca0.tar.gz rust-b6eeb4ee90e31f7846e94e4f639f44bc5f623ca0.zip | |
Assume masks are correct
This allows miri to detect when they are not, and may be exploited by LLVM during optimization.
| -rw-r--r-- | crates/core_simd/src/lib.rs | 1 | ||||
| -rw-r--r-- | crates/core_simd/src/masks.rs | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index 64ba9705ef5..e974e7aa25a 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -4,6 +4,7 @@ const_maybe_uninit_as_mut_ptr, const_mut_refs, convert_float_to_int, + core_intrinsics, decl_macro, inline_const, intra_doc_pointers, diff --git a/crates/core_simd/src/masks.rs b/crates/core_simd/src/masks.rs index 0623d2bf3d1..b95c070d09c 100644 --- a/crates/core_simd/src/masks.rs +++ b/crates/core_simd/src/masks.rs @@ -175,7 +175,10 @@ where #[must_use = "method returns a new mask and does not mutate the original value"] pub unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self { // Safety: the caller must confirm this invariant - unsafe { Self(mask_impl::Mask::from_int_unchecked(value)) } + unsafe { + core::intrinsics::assume(<T as Sealed>::valid(value)); + Self(mask_impl::Mask::from_int_unchecked(value)) + } } /// Converts a vector of integers to a mask, where 0 represents `false` and -1 |
