Skip to content

Commit 3a70dd6

Browse files
committed
Rename Mask::from_int_unchecked to Mask::from_simd_unchecked
1 parent 42409f0 commit 3a70dd6

File tree

7 files changed

+39
-37
lines changed

7 files changed

+39
-37
lines changed

crates/core_simd/src/masks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ where
157157
let bytes: [u8; N] = mem::transmute_copy(&array);
158158
let bools: Simd<i8, N> =
159159
core::intrinsics::simd::simd_ne(Simd::from_array(bytes), Simd::splat(0u8));
160-
Mask::from_int_unchecked(core::intrinsics::simd::simd_cast(bools))
160+
Mask::from_simd_unchecked(core::intrinsics::simd::simd_cast(bools))
161161
}
162162
}
163163

@@ -188,11 +188,11 @@ where
188188
/// All elements must be either 0 or -1.
189189
#[inline]
190190
#[must_use = "method returns a new mask and does not mutate the original value"]
191-
pub unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
191+
pub unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
192192
// Safety: the caller must confirm this invariant
193193
unsafe {
194194
core::intrinsics::assume(<T as Sealed>::valid(value));
195-
Self(mask_impl::Mask::from_int_unchecked(value))
195+
Self(mask_impl::Mask::from_simd_unchecked(value))
196196
}
197197
}
198198

@@ -207,7 +207,7 @@ where
207207
pub fn from_simd(value: Simd<T, N>) -> Self {
208208
assert!(T::valid(value), "all values must be either 0 or -1",);
209209
// Safety: the validity has been checked
210-
unsafe { Self::from_int_unchecked(value) }
210+
unsafe { Self::from_simd_unchecked(value) }
211211
}
212212

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

crates/core_simd/src/masks/bitmask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ where
117117

118118
#[inline]
119119
#[must_use = "method returns a new mask and does not mutate the original value"]
120-
pub(crate) unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
120+
pub(crate) unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
121121
unsafe { Self(core::intrinsics::simd::simd_bitmask(value), PhantomData) }
122122
}
123123

crates/core_simd/src/masks/full_masks.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ where
126126

127127
#[inline]
128128
#[must_use = "method returns a new mask and does not mutate the original value"]
129-
pub(crate) unsafe fn from_int_unchecked(value: Simd<T, N>) -> Self {
129+
pub(crate) unsafe fn from_simd_unchecked(value: Simd<T, N>) -> Self {
130130
Self(value)
131131
}
132132

@@ -180,7 +180,7 @@ where
180180
};
181181

182182
// SAFETY: `mask` only contains `T::TRUE` or `T::FALSE`
183-
unsafe { Self::from_int_unchecked(mask.resize::<N>(T::FALSE)) }
183+
unsafe { Self::from_simd_unchecked(mask.resize::<N>(T::FALSE)) }
184184
}
185185

186186
#[inline]

crates/core_simd/src/simd/cmp/eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ macro_rules! impl_number {
3030
fn simd_eq(self, other: Self) -> Self::Mask {
3131
// Safety: `self` is a vector, and the result of the comparison
3232
// is always a valid mask.
33-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_eq(self, other)) }
33+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_eq(self, other)) }
3434
}
3535

3636
#[inline]
3737
fn simd_ne(self, other: Self) -> Self::Mask {
3838
// Safety: `self` is a vector, and the result of the comparison
3939
// is always a valid mask.
40-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ne(self, other)) }
40+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ne(self, other)) }
4141
}
4242
}
4343
)*
@@ -59,14 +59,14 @@ macro_rules! impl_mask {
5959
fn simd_eq(self, other: Self) -> Self::Mask {
6060
// Safety: `self` is a vector, and the result of the comparison
6161
// is always a valid mask.
62-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_eq(self.to_simd(), other.to_simd())) }
62+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_eq(self.to_simd(), other.to_simd())) }
6363
}
6464

6565
#[inline]
6666
fn simd_ne(self, other: Self) -> Self::Mask {
6767
// Safety: `self` is a vector, and the result of the comparison
6868
// is always a valid mask.
69-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ne(self.to_simd(), other.to_simd())) }
69+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_ne(self.to_simd(), other.to_simd())) }
7070
}
7171
}
7272
)*

crates/core_simd/src/simd/cmp/ord.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,28 @@ macro_rules! impl_integer {
5656
fn simd_lt(self, other: Self) -> Self::Mask {
5757
// Safety: `self` is a vector, and the result of the comparison
5858
// is always a valid mask.
59-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
59+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
6060
}
6161

6262
#[inline]
6363
fn simd_le(self, other: Self) -> Self::Mask {
6464
// Safety: `self` is a vector, and the result of the comparison
6565
// is always a valid mask.
66-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_le(self, other)) }
66+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_le(self, other)) }
6767
}
6868

6969
#[inline]
7070
fn simd_gt(self, other: Self) -> Self::Mask {
7171
// Safety: `self` is a vector, and the result of the comparison
7272
// is always a valid mask.
73-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
73+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
7474
}
7575

7676
#[inline]
7777
fn simd_ge(self, other: Self) -> Self::Mask {
7878
// Safety: `self` is a vector, and the result of the comparison
7979
// is always a valid mask.
80-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
80+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
8181
}
8282
}
8383

@@ -122,28 +122,28 @@ macro_rules! impl_float {
122122
fn simd_lt(self, other: Self) -> Self::Mask {
123123
// Safety: `self` is a vector, and the result of the comparison
124124
// is always a valid mask.
125-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
125+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_lt(self, other)) }
126126
}
127127

128128
#[inline]
129129
fn simd_le(self, other: Self) -> Self::Mask {
130130
// Safety: `self` is a vector, and the result of the comparison
131131
// is always a valid mask.
132-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_le(self, other)) }
132+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_le(self, other)) }
133133
}
134134

135135
#[inline]
136136
fn simd_gt(self, other: Self) -> Self::Mask {
137137
// Safety: `self` is a vector, and the result of the comparison
138138
// is always a valid mask.
139-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
139+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_gt(self, other)) }
140140
}
141141

142142
#[inline]
143143
fn simd_ge(self, other: Self) -> Self::Mask {
144144
// Safety: `self` is a vector, and the result of the comparison
145145
// is always a valid mask.
146-
unsafe { Mask::from_int_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
146+
unsafe { Mask::from_simd_unchecked(core::intrinsics::simd::simd_ge(self, other)) }
147147
}
148148
}
149149
)*
@@ -163,28 +163,28 @@ macro_rules! impl_mask {
163163
fn simd_lt(self, other: Self) -> Self::Mask {
164164
// Safety: `self` is a vector, and the result of the comparison
165165
// is always a valid mask.
166-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_lt(self.to_simd(), other.to_simd())) }
166+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_lt(self.to_simd(), other.to_simd())) }
167167
}
168168

169169
#[inline]
170170
fn simd_le(self, other: Self) -> Self::Mask {
171171
// Safety: `self` is a vector, and the result of the comparison
172172
// is always a valid mask.
173-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_le(self.to_simd(), other.to_simd())) }
173+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_le(self.to_simd(), other.to_simd())) }
174174
}
175175

176176
#[inline]
177177
fn simd_gt(self, other: Self) -> Self::Mask {
178178
// Safety: `self` is a vector, and the result of the comparison
179179
// is always a valid mask.
180-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_gt(self.to_simd(), other.to_simd())) }
180+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_gt(self.to_simd(), other.to_simd())) }
181181
}
182182

183183
#[inline]
184184
fn simd_ge(self, other: Self) -> Self::Mask {
185185
// Safety: `self` is a vector, and the result of the comparison
186186
// is always a valid mask.
187-
unsafe { Self::from_int_unchecked(core::intrinsics::simd::simd_ge(self.to_simd(), other.to_simd())) }
187+
unsafe { Self::from_simd_unchecked(core::intrinsics::simd::simd_ge(self.to_simd(), other.to_simd())) }
188188
}
189189
}
190190

crates/core_simd/src/swizzle.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub trait Swizzle<const N: usize> {
165165
LaneCount<M>: SupportedLaneCount,
166166
{
167167
// SAFETY: all elements of this mask come from another mask
168-
unsafe { Mask::from_int_unchecked(Self::swizzle(mask.to_simd())) }
168+
unsafe { Mask::from_simd_unchecked(Self::swizzle(mask.to_simd())) }
169169
}
170170

171171
/// Creates a new mask from the elements of `first` and `second`.
@@ -181,7 +181,9 @@ pub trait Swizzle<const N: usize> {
181181
LaneCount<M>: SupportedLaneCount,
182182
{
183183
// SAFETY: all elements of this mask come from another mask
184-
unsafe { Mask::from_int_unchecked(Self::concat_swizzle(first.to_simd(), second.to_simd())) }
184+
unsafe {
185+
Mask::from_simd_unchecked(Self::concat_swizzle(first.to_simd(), second.to_simd()))
186+
}
185187
}
186188
}
187189

@@ -524,7 +526,7 @@ where
524526
#[must_use = "method returns a new vector and does not mutate the original inputs"]
525527
pub fn reverse(self) -> Self {
526528
// Safety: swizzles are safe for masks
527-
unsafe { Self::from_int_unchecked(self.to_simd().reverse()) }
529+
unsafe { Self::from_simd_unchecked(self.to_simd().reverse()) }
528530
}
529531

530532
/// Rotates the mask such that the first `OFFSET` elements of the slice move to the end
@@ -534,7 +536,7 @@ where
534536
#[must_use = "method returns a new vector and does not mutate the original inputs"]
535537
pub fn rotate_elements_left<const OFFSET: usize>(self) -> Self {
536538
// Safety: swizzles are safe for masks
537-
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_left::<OFFSET>()) }
539+
unsafe { Self::from_simd_unchecked(self.to_simd().rotate_elements_left::<OFFSET>()) }
538540
}
539541

540542
/// Rotates the mask such that the first `self.len() - OFFSET` elements of the mask move to
@@ -544,7 +546,7 @@ where
544546
#[must_use = "method returns a new vector and does not mutate the original inputs"]
545547
pub fn rotate_elements_right<const OFFSET: usize>(self) -> Self {
546548
// Safety: swizzles are safe for masks
547-
unsafe { Self::from_int_unchecked(self.to_simd().rotate_elements_right::<OFFSET>()) }
549+
unsafe { Self::from_simd_unchecked(self.to_simd().rotate_elements_right::<OFFSET>()) }
548550
}
549551

550552
/// Shifts the mask elements to the left by `OFFSET`, filling in with
@@ -554,7 +556,7 @@ where
554556
pub fn shift_elements_left<const OFFSET: usize>(self, padding: bool) -> Self {
555557
// Safety: swizzles are safe for masks
556558
unsafe {
557-
Self::from_int_unchecked(self.to_simd().shift_elements_left::<OFFSET>(if padding {
559+
Self::from_simd_unchecked(self.to_simd().shift_elements_left::<OFFSET>(if padding {
558560
T::TRUE
559561
} else {
560562
T::FALSE
@@ -569,7 +571,7 @@ where
569571
pub fn shift_elements_right<const OFFSET: usize>(self, padding: bool) -> Self {
570572
// Safety: swizzles are safe for masks
571573
unsafe {
572-
Self::from_int_unchecked(self.to_simd().shift_elements_right::<OFFSET>(if padding {
574+
Self::from_simd_unchecked(self.to_simd().shift_elements_right::<OFFSET>(if padding {
573575
T::TRUE
574576
} else {
575577
T::FALSE
@@ -600,7 +602,7 @@ where
600602
pub fn interleave(self, other: Self) -> (Self, Self) {
601603
let (lo, hi) = self.to_simd().interleave(other.to_simd());
602604
// Safety: swizzles are safe for masks
603-
unsafe { (Self::from_int_unchecked(lo), Self::from_int_unchecked(hi)) }
605+
unsafe { (Self::from_simd_unchecked(lo), Self::from_simd_unchecked(hi)) }
604606
}
605607

606608
/// Deinterleave two masks.
@@ -631,8 +633,8 @@ where
631633
// Safety: swizzles are safe for masks
632634
unsafe {
633635
(
634-
Self::from_int_unchecked(even),
635-
Self::from_int_unchecked(odd),
636+
Self::from_simd_unchecked(even),
637+
Self::from_simd_unchecked(odd),
636638
)
637639
}
638640
}
@@ -659,7 +661,7 @@ where
659661
{
660662
// Safety: swizzles are safe for masks
661663
unsafe {
662-
Mask::<T, M>::from_int_unchecked(self.to_simd().resize::<M>(if value {
664+
Mask::<T, M>::from_simd_unchecked(self.to_simd().resize::<M>(if value {
663665
T::TRUE
664666
} else {
665667
T::FALSE
@@ -684,6 +686,6 @@ where
684686
LaneCount<LEN>: SupportedLaneCount,
685687
{
686688
// Safety: swizzles are safe for masks
687-
unsafe { Mask::<T, LEN>::from_int_unchecked(self.to_simd().extract::<START, LEN>()) }
689+
unsafe { Mask::<T, LEN>::from_simd_unchecked(self.to_simd().extract::<START, LEN>()) }
688690
}
689691
}

crates/core_simd/src/vector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ where
926926
let mask = unsafe {
927927
let tfvec: Simd<<T as SimdElement>::Mask, N> =
928928
core::intrinsics::simd::simd_eq(*self, *other);
929-
Mask::from_int_unchecked(tfvec)
929+
Mask::from_simd_unchecked(tfvec)
930930
};
931931

932932
// Two vectors are equal if all elements are equal when compared elementwise
@@ -940,7 +940,7 @@ where
940940
let mask = unsafe {
941941
let tfvec: Simd<<T as SimdElement>::Mask, N> =
942942
core::intrinsics::simd::simd_ne(*self, *other);
943-
Mask::from_int_unchecked(tfvec)
943+
Mask::from_simd_unchecked(tfvec)
944944
};
945945

946946
// Two vectors are non-equal if any elements are non-equal when compared elementwise

0 commit comments

Comments
 (0)