Skip to content

Commit e6a5309

Browse files
committed
Reduce maximum lanes from 64 to 32
1 parent 97bbe2d commit e6a5309

File tree

18 files changed

+212
-228
lines changed

18 files changed

+212
-228
lines changed

Diff for: crates/core_simd/src/comparisons.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
use crate::LanesAtMost64;
1+
use crate::LanesAtMost32;
22

33
macro_rules! implement_mask_ops {
44
{ $($vector:ident => $mask:ident ($inner_mask_ty:ident, $inner_ty:ident),)* } => {
55
$(
66
impl<const LANES: usize> crate::$vector<LANES>
77
where
8-
crate::$vector<LANES>: LanesAtMost64,
9-
crate::$inner_ty<LANES>: LanesAtMost64,
8+
crate::$vector<LANES>: LanesAtMost32,
9+
crate::$inner_ty<LANES>: LanesAtMost32,
1010
{
1111
/// Test if each lane is equal to the corresponding lane in `other`.
1212
#[inline]

Diff for: crates/core_simd/src/first.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Implements common traits on the specified vector `$name`, holding multiple `$lanes` of `$type`.
22
macro_rules! impl_vector {
33
{ $name:ident, $type:ty } => {
4-
impl<const LANES: usize> $name<LANES> where Self: crate::LanesAtMost64 {
4+
impl<const LANES: usize> $name<LANES> where Self: crate::LanesAtMost32 {
55
/// Construct a SIMD vector by setting all lanes to the given value.
66
pub const fn splat(value: $type) -> Self {
77
Self([value; LANES])
@@ -44,31 +44,31 @@ macro_rules! impl_vector {
4444
}
4545
}
4646

47-
impl<const LANES: usize> Copy for $name<LANES> where Self: crate::LanesAtMost64 {}
47+
impl<const LANES: usize> Copy for $name<LANES> where Self: crate::LanesAtMost32 {}
4848

49-
impl<const LANES: usize> Clone for $name<LANES> where Self: crate::LanesAtMost64 {
49+
impl<const LANES: usize> Clone for $name<LANES> where Self: crate::LanesAtMost32 {
5050
#[inline]
5151
fn clone(&self) -> Self {
5252
*self
5353
}
5454
}
5555

56-
impl<const LANES: usize> Default for $name<LANES> where Self: crate::LanesAtMost64 {
56+
impl<const LANES: usize> Default for $name<LANES> where Self: crate::LanesAtMost32 {
5757
#[inline]
5858
fn default() -> Self {
5959
Self::splat(<$type>::default())
6060
}
6161
}
6262

63-
impl<const LANES: usize> PartialEq for $name<LANES> where Self: crate::LanesAtMost64 {
63+
impl<const LANES: usize> PartialEq for $name<LANES> where Self: crate::LanesAtMost32 {
6464
#[inline]
6565
fn eq(&self, other: &Self) -> bool {
6666
// TODO use SIMD equality
6767
self.to_array() == other.to_array()
6868
}
6969
}
7070

71-
impl<const LANES: usize> PartialOrd for $name<LANES> where Self: crate::LanesAtMost64 {
71+
impl<const LANES: usize> PartialOrd for $name<LANES> where Self: crate::LanesAtMost32 {
7272
#[inline]
7373
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
7474
// TODO use SIMD equalitya
@@ -77,43 +77,43 @@ macro_rules! impl_vector {
7777
}
7878

7979
// array references
80-
impl<const LANES: usize> AsRef<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost64 {
80+
impl<const LANES: usize> AsRef<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost32 {
8181
#[inline]
8282
fn as_ref(&self) -> &[$type; LANES] {
8383
&self.0
8484
}
8585
}
8686

87-
impl<const LANES: usize> AsMut<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost64 {
87+
impl<const LANES: usize> AsMut<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost32 {
8888
#[inline]
8989
fn as_mut(&mut self) -> &mut [$type; LANES] {
9090
&mut self.0
9191
}
9292
}
9393

9494
// slice references
95-
impl<const LANES: usize> AsRef<[$type]> for $name<LANES> where Self: crate::LanesAtMost64 {
95+
impl<const LANES: usize> AsRef<[$type]> for $name<LANES> where Self: crate::LanesAtMost32 {
9696
#[inline]
9797
fn as_ref(&self) -> &[$type] {
9898
&self.0
9999
}
100100
}
101101

102-
impl<const LANES: usize> AsMut<[$type]> for $name<LANES> where Self: crate::LanesAtMost64 {
102+
impl<const LANES: usize> AsMut<[$type]> for $name<LANES> where Self: crate::LanesAtMost32 {
103103
#[inline]
104104
fn as_mut(&mut self) -> &mut [$type] {
105105
&mut self.0
106106
}
107107
}
108108

109109
// vector/array conversion
110-
impl<const LANES: usize> From<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost64 {
110+
impl<const LANES: usize> From<[$type; LANES]> for $name<LANES> where Self: crate::LanesAtMost32 {
111111
fn from(array: [$type; LANES]) -> Self {
112112
Self(array)
113113
}
114114
}
115115

116-
impl <const LANES: usize> From<$name<LANES>> for [$type; LANES] where $name<LANES>: crate::LanesAtMost64 {
116+
impl <const LANES: usize> From<$name<LANES>> for [$type; LANES] where $name<LANES>: crate::LanesAtMost32 {
117117
fn from(vector: $name<LANES>) -> Self {
118118
vector.to_array()
119119
}

Diff for: crates/core_simd/src/fmt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ macro_rules! impl_fmt_trait {
3535
$( // repeat trait
3636
impl<const LANES: usize> core::fmt::$trait for crate::$type<LANES>
3737
where
38-
Self: crate::LanesAtMost64,
38+
Self: crate::LanesAtMost32,
3939
{
4040
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
4141
$format(self.as_ref(), f)

Diff for: crates/core_simd/src/intrinsics.rs

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ extern "platform-intrinsic" {
6161
pub(crate) fn simd_shuffle8<T, U>(x: T, y: T, idx: [u32; 8]) -> U;
6262
pub(crate) fn simd_shuffle16<T, U>(x: T, y: T, idx: [u32; 16]) -> U;
6363
pub(crate) fn simd_shuffle32<T, U>(x: T, y: T, idx: [u32; 32]) -> U;
64-
pub(crate) fn simd_shuffle64<T, U>(x: T, y: T, idx: [u32; 64]) -> U;
6564

6665
// {s,u}add.sat
6766
pub(crate) fn simd_saturating_add<T>(x: T, y: T) -> T;

Diff for: crates/core_simd/src/lanes_at_most_64.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/// Implemented for bitmask sizes that are supported by the implementation.
2-
pub trait LanesAtMost64 {}
2+
pub trait LanesAtMost32 {}
33

44
macro_rules! impl_for {
55
{ $name:ident } => {
6-
impl LanesAtMost64 for $name<1> {}
7-
impl LanesAtMost64 for $name<2> {}
8-
impl LanesAtMost64 for $name<4> {}
9-
impl LanesAtMost64 for $name<8> {}
10-
impl LanesAtMost64 for $name<16> {}
11-
impl LanesAtMost64 for $name<32> {}
12-
impl LanesAtMost64 for $name<64> {}
6+
impl LanesAtMost32 for $name<1> {}
7+
impl LanesAtMost32 for $name<2> {}
8+
impl LanesAtMost32 for $name<4> {}
9+
impl LanesAtMost32 for $name<8> {}
10+
impl LanesAtMost32 for $name<16> {}
11+
impl LanesAtMost32 for $name<32> {}
1312
}
1413
}
1514

Diff for: crates/core_simd/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod round;
2121
mod math;
2222

2323
mod lanes_at_most_64;
24-
pub use lanes_at_most_64::LanesAtMost64;
24+
pub use lanes_at_most_64::LanesAtMost32;
2525

2626
mod masks;
2727
pub use masks::*;

Diff for: crates/core_simd/src/masks/bitmask.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
use crate::LanesAtMost64;
1+
use crate::LanesAtMost32;
22

33
/// A mask where each lane is represented by a single bit.
44
#[derive(Copy, Clone, Debug)]
55
#[repr(transparent)]
66
pub struct BitMask<const LANES: usize>(u64)
77
where
8-
BitMask<LANES>: LanesAtMost64;
8+
BitMask<LANES>: LanesAtMost32;
99

1010
impl<const LANES: usize> BitMask<LANES>
1111
where
12-
Self: LanesAtMost64,
12+
Self: LanesAtMost32,
1313
{
1414
/// Construct a mask by setting all lanes to the given value.
1515
pub fn splat(value: bool) -> Self {
@@ -43,7 +43,7 @@ where
4343

4444
impl<const LANES: usize> core::ops::BitAnd for BitMask<LANES>
4545
where
46-
Self: LanesAtMost64,
46+
Self: LanesAtMost32,
4747
{
4848
type Output = Self;
4949
#[inline]
@@ -54,7 +54,7 @@ where
5454

5555
impl<const LANES: usize> core::ops::BitAnd<bool> for BitMask<LANES>
5656
where
57-
Self: LanesAtMost64,
57+
Self: LanesAtMost32,
5858
{
5959
type Output = Self;
6060
#[inline]
@@ -65,7 +65,7 @@ where
6565

6666
impl<const LANES: usize> core::ops::BitAnd<BitMask<LANES>> for bool
6767
where
68-
BitMask<LANES>: LanesAtMost64,
68+
BitMask<LANES>: LanesAtMost32,
6969
{
7070
type Output = BitMask<LANES>;
7171
#[inline]
@@ -76,7 +76,7 @@ where
7676

7777
impl<const LANES: usize> core::ops::BitOr for BitMask<LANES>
7878
where
79-
Self: LanesAtMost64,
79+
Self: LanesAtMost32,
8080
{
8181
type Output = Self;
8282
#[inline]
@@ -87,7 +87,7 @@ where
8787

8888
impl<const LANES: usize> core::ops::BitOr<bool> for BitMask<LANES>
8989
where
90-
Self: LanesAtMost64,
90+
Self: LanesAtMost32,
9191
{
9292
type Output = Self;
9393
#[inline]
@@ -98,7 +98,7 @@ where
9898

9999
impl<const LANES: usize> core::ops::BitOr<BitMask<LANES>> for bool
100100
where
101-
BitMask<LANES>: LanesAtMost64,
101+
BitMask<LANES>: LanesAtMost32,
102102
{
103103
type Output = BitMask<LANES>;
104104
#[inline]
@@ -109,7 +109,7 @@ where
109109

110110
impl<const LANES: usize> core::ops::BitXor for BitMask<LANES>
111111
where
112-
Self: LanesAtMost64,
112+
Self: LanesAtMost32,
113113
{
114114
type Output = Self;
115115
#[inline]
@@ -120,7 +120,7 @@ where
120120

121121
impl<const LANES: usize> core::ops::BitXor<bool> for BitMask<LANES>
122122
where
123-
Self: LanesAtMost64,
123+
Self: LanesAtMost32,
124124
{
125125
type Output = Self;
126126
#[inline]
@@ -131,7 +131,7 @@ where
131131

132132
impl<const LANES: usize> core::ops::BitXor<BitMask<LANES>> for bool
133133
where
134-
BitMask<LANES>: LanesAtMost64,
134+
BitMask<LANES>: LanesAtMost32,
135135
{
136136
type Output = BitMask<LANES>;
137137
#[inline]
@@ -142,7 +142,7 @@ where
142142

143143
impl<const LANES: usize> core::ops::Not for BitMask<LANES>
144144
where
145-
Self: LanesAtMost64,
145+
Self: LanesAtMost32,
146146
{
147147
type Output = BitMask<LANES>;
148148
#[inline]
@@ -153,7 +153,7 @@ where
153153

154154
impl<const LANES: usize> core::ops::BitAndAssign for BitMask<LANES>
155155
where
156-
Self: LanesAtMost64,
156+
Self: LanesAtMost32,
157157
{
158158
#[inline]
159159
fn bitand_assign(&mut self, rhs: Self) {
@@ -163,7 +163,7 @@ where
163163

164164
impl<const LANES: usize> core::ops::BitAndAssign<bool> for BitMask<LANES>
165165
where
166-
Self: LanesAtMost64,
166+
Self: LanesAtMost32,
167167
{
168168
#[inline]
169169
fn bitand_assign(&mut self, rhs: bool) {
@@ -173,7 +173,7 @@ where
173173

174174
impl<const LANES: usize> core::ops::BitOrAssign for BitMask<LANES>
175175
where
176-
Self: LanesAtMost64,
176+
Self: LanesAtMost32,
177177
{
178178
#[inline]
179179
fn bitor_assign(&mut self, rhs: Self) {
@@ -183,7 +183,7 @@ where
183183

184184
impl<const LANES: usize> core::ops::BitOrAssign<bool> for BitMask<LANES>
185185
where
186-
Self: LanesAtMost64,
186+
Self: LanesAtMost32,
187187
{
188188
#[inline]
189189
fn bitor_assign(&mut self, rhs: bool) {
@@ -193,7 +193,7 @@ where
193193

194194
impl<const LANES: usize> core::ops::BitXorAssign for BitMask<LANES>
195195
where
196-
Self: LanesAtMost64,
196+
Self: LanesAtMost32,
197197
{
198198
#[inline]
199199
fn bitxor_assign(&mut self, rhs: Self) {
@@ -203,7 +203,7 @@ where
203203

204204
impl<const LANES: usize> core::ops::BitXorAssign<bool> for BitMask<LANES>
205205
where
206-
Self: LanesAtMost64,
206+
Self: LanesAtMost32,
207207
{
208208
#[inline]
209209
fn bitxor_assign(&mut self, rhs: bool) {

0 commit comments

Comments
 (0)