Skip to content

Commit 6ad779c

Browse files
Merge pull request #385 from workingjubilee/make-an-ass-out-of-u-and-me
Assume masks are correct
2 parents b2e1bcb + b6eeb4e commit 6ad779c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/core_simd/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
const_maybe_uninit_as_mut_ptr,
77
const_mut_refs,
88
convert_float_to_int,
9+
core_intrinsics,
910
decl_macro,
1011
inline_const,
1112
intra_doc_pointers,

crates/core_simd/src/masks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,10 @@ where
174174
#[must_use = "method returns a new mask and does not mutate the original value"]
175175
pub unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
176176
// Safety: the caller must confirm this invariant
177-
unsafe { Self(mask_impl::Mask::from_int_unchecked(value)) }
177+
unsafe {
178+
core::intrinsics::assume(<T as Sealed>::valid(value));
179+
Self(mask_impl::Mask::from_int_unchecked(value))
180+
}
178181
}
179182

180183
/// Converts a vector of integers to a mask, where 0 represents `false` and -1

0 commit comments

Comments
 (0)