Assume masks are correct

This allows miri to detect when they are not, and
may be exploited by LLVM during optimization.
This commit is contained in:
Jubilee Young 2023-12-13 17:46:46 -08:00
parent 1273da658e
commit b6eeb4ee90
2 changed files with 5 additions and 1 deletions

View File

@ -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,

View File

@ -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