Skip to content

Commit 8ce88bc

Browse files
Remove LaneCount in favor of #[rustc_simd_monomorphize_lane_limit] attribute (#485)
* Remove LaneCount in favor of #[rustc_simd_monomorphize_lane_limit] attribute * Document allowed vector lengths
1 parent 32ba8ed commit 8ce88bc

File tree

26 files changed

+57
-304
lines changed

26 files changed

+57
-304
lines changed

crates/core_simd/src/fmt.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
1+
use crate::simd::{Simd, SimdElement};
22
use core::fmt;
33

44
impl<T, const N: usize> fmt::Debug for Simd<T, N>
55
where
6-
LaneCount<N>: SupportedLaneCount,
76
T: SimdElement + fmt::Debug,
87
{
98
/// A `Simd<T, N>` has a debug format like the one for `[T]`:

crates/core_simd/src/iter.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::simd::{LaneCount, Simd, SupportedLaneCount};
1+
use crate::simd::Simd;
22
use core::{
33
iter::{Product, Sum},
44
ops::{Add, Mul},
@@ -7,8 +7,6 @@ use core::{
77
macro_rules! impl_traits {
88
{ $type:ty } => {
99
impl<const N: usize> Sum<Self> for Simd<$type, N>
10-
where
11-
LaneCount<N>: SupportedLaneCount,
1210
{
1311
#[inline]
1412
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
@@ -17,8 +15,6 @@ macro_rules! impl_traits {
1715
}
1816

1917
impl<const N: usize> Product<Self> for Simd<$type, N>
20-
where
21-
LaneCount<N>: SupportedLaneCount,
2218
{
2319
#[inline]
2420
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
@@ -27,8 +23,6 @@ macro_rules! impl_traits {
2723
}
2824

2925
impl<'a, const N: usize> Sum<&'a Self> for Simd<$type, N>
30-
where
31-
LaneCount<N>: SupportedLaneCount,
3226
{
3327
#[inline]
3428
fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self {
@@ -37,8 +31,6 @@ macro_rules! impl_traits {
3731
}
3832

3933
impl<'a, const N: usize> Product<&'a Self> for Simd<$type, N>
40-
where
41-
LaneCount<N>: SupportedLaneCount,
4234
{
4335
#[inline]
4436
fn product<I: Iterator<Item = &'a Self>>(iter: I) -> Self {

crates/core_simd/src/lane_count.rs

Lines changed: 0 additions & 52 deletions
This file was deleted.

crates/core_simd/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
simd_ffi,
1010
staged_api,
1111
prelude_import,
12-
ptr_metadata
12+
ptr_metadata,
13+
rustc_attrs
1314
)]
1415
#![cfg_attr(
1516
all(

crates/core_simd/src/masks.rs

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! Types representing
33
#![allow(non_camel_case_types)]
44

5-
use crate::simd::{LaneCount, Select, Simd, SimdCast, SimdElement, SupportedLaneCount};
5+
use crate::simd::{Select, Simd, SimdCast, SimdElement};
66
use core::cmp::Ordering;
77
use core::{fmt, mem};
88

@@ -41,7 +41,6 @@ mod sealed {
4141
pub trait Sealed {
4242
fn valid<const N: usize>(values: Simd<Self, N>) -> bool
4343
where
44-
LaneCount<N>: SupportedLaneCount,
4544
Self: SimdElement;
4645

4746
fn eq(self, other: Self) -> bool;
@@ -69,8 +68,6 @@ macro_rules! impl_element {
6968
impl Sealed for $ty {
7069
#[inline]
7170
fn valid<const N: usize>(value: Simd<Self, N>) -> bool
72-
where
73-
LaneCount<N>: SupportedLaneCount,
7471
{
7572
// We can't use `Simd` directly, because `Simd`'s functions call this function and
7673
// we will end up with an infinite loop.
@@ -121,23 +118,19 @@ impl_element! { isize, usize }
121118
/// The layout of this type is unspecified, and may change between platforms
122119
/// and/or Rust versions, and code should not assume that it is equivalent to
123120
/// `[T; N]`.
121+
///
122+
/// `N` cannot be 0 and may be at most 64. This limit may be increased in
123+
/// the future.
124124
#[repr(transparent)]
125125
pub struct Mask<T, const N: usize>(Simd<T, N>)
126126
where
127-
T: MaskElement,
128-
LaneCount<N>: SupportedLaneCount;
127+
T: MaskElement;
129128

130-
impl<T, const N: usize> Copy for Mask<T, N>
131-
where
132-
T: MaskElement,
133-
LaneCount<N>: SupportedLaneCount,
134-
{
135-
}
129+
impl<T, const N: usize> Copy for Mask<T, N> where T: MaskElement {}
136130

137131
impl<T, const N: usize> Clone for Mask<T, N>
138132
where
139133
T: MaskElement,
140-
LaneCount<N>: SupportedLaneCount,
141134
{
142135
#[inline]
143136
fn clone(&self) -> Self {
@@ -148,7 +141,6 @@ where
148141
impl<T, const N: usize> Mask<T, N>
149142
where
150143
T: MaskElement,
151-
LaneCount<N>: SupportedLaneCount,
152144
{
153145
/// Constructs a mask by setting all elements to the given value.
154146
#[inline]
@@ -315,8 +307,6 @@ where
315307
) -> U
316308
where
317309
T: MaskElement,
318-
LaneCount<M>: SupportedLaneCount,
319-
LaneCount<N>: SupportedLaneCount,
320310
{
321311
let resized = mask.resize::<M>(false);
322312

@@ -421,7 +411,6 @@ where
421411
impl<T, const N: usize> From<[bool; N]> for Mask<T, N>
422412
where
423413
T: MaskElement,
424-
LaneCount<N>: SupportedLaneCount,
425414
{
426415
#[inline]
427416
fn from(array: [bool; N]) -> Self {
@@ -432,7 +421,6 @@ where
432421
impl<T, const N: usize> From<Mask<T, N>> for [bool; N]
433422
where
434423
T: MaskElement,
435-
LaneCount<N>: SupportedLaneCount,
436424
{
437425
#[inline]
438426
fn from(vector: Mask<T, N>) -> Self {
@@ -443,7 +431,6 @@ where
443431
impl<T, const N: usize> Default for Mask<T, N>
444432
where
445433
T: MaskElement,
446-
LaneCount<N>: SupportedLaneCount,
447434
{
448435
#[inline]
449436
fn default() -> Self {
@@ -454,7 +441,6 @@ where
454441
impl<T, const N: usize> PartialEq for Mask<T, N>
455442
where
456443
T: MaskElement + PartialEq,
457-
LaneCount<N>: SupportedLaneCount,
458444
{
459445
#[inline]
460446
fn eq(&self, other: &Self) -> bool {
@@ -465,7 +451,6 @@ where
465451
impl<T, const N: usize> PartialOrd for Mask<T, N>
466452
where
467453
T: MaskElement + PartialOrd,
468-
LaneCount<N>: SupportedLaneCount,
469454
{
470455
#[inline]
471456
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
@@ -476,7 +461,6 @@ where
476461
impl<T, const N: usize> fmt::Debug for Mask<T, N>
477462
where
478463
T: MaskElement + fmt::Debug,
479-
LaneCount<N>: SupportedLaneCount,
480464
{
481465
#[inline]
482466
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -489,7 +473,6 @@ where
489473
impl<T, const N: usize> core::ops::BitAnd for Mask<T, N>
490474
where
491475
T: MaskElement,
492-
LaneCount<N>: SupportedLaneCount,
493476
{
494477
type Output = Self;
495478
#[inline]
@@ -502,7 +485,6 @@ where
502485
impl<T, const N: usize> core::ops::BitAnd<bool> for Mask<T, N>
503486
where
504487
T: MaskElement,
505-
LaneCount<N>: SupportedLaneCount,
506488
{
507489
type Output = Self;
508490
#[inline]
@@ -514,7 +496,6 @@ where
514496
impl<T, const N: usize> core::ops::BitAnd<Mask<T, N>> for bool
515497
where
516498
T: MaskElement,
517-
LaneCount<N>: SupportedLaneCount,
518499
{
519500
type Output = Mask<T, N>;
520501
#[inline]
@@ -526,7 +507,6 @@ where
526507
impl<T, const N: usize> core::ops::BitOr for Mask<T, N>
527508
where
528509
T: MaskElement,
529-
LaneCount<N>: SupportedLaneCount,
530510
{
531511
type Output = Self;
532512
#[inline]
@@ -539,7 +519,6 @@ where
539519
impl<T, const N: usize> core::ops::BitOr<bool> for Mask<T, N>
540520
where
541521
T: MaskElement,
542-
LaneCount<N>: SupportedLaneCount,
543522
{
544523
type Output = Self;
545524
#[inline]
@@ -551,7 +530,6 @@ where
551530
impl<T, const N: usize> core::ops::BitOr<Mask<T, N>> for bool
552531
where
553532
T: MaskElement,
554-
LaneCount<N>: SupportedLaneCount,
555533
{
556534
type Output = Mask<T, N>;
557535
#[inline]
@@ -563,7 +541,6 @@ where
563541
impl<T, const N: usize> core::ops::BitXor for Mask<T, N>
564542
where
565543
T: MaskElement,
566-
LaneCount<N>: SupportedLaneCount,
567544
{
568545
type Output = Self;
569546
#[inline]
@@ -576,7 +553,6 @@ where
576553
impl<T, const N: usize> core::ops::BitXor<bool> for Mask<T, N>
577554
where
578555
T: MaskElement,
579-
LaneCount<N>: SupportedLaneCount,
580556
{
581557
type Output = Self;
582558
#[inline]
@@ -588,7 +564,6 @@ where
588564
impl<T, const N: usize> core::ops::BitXor<Mask<T, N>> for bool
589565
where
590566
T: MaskElement,
591-
LaneCount<N>: SupportedLaneCount,
592567
{
593568
type Output = Mask<T, N>;
594569
#[inline]
@@ -600,7 +575,6 @@ where
600575
impl<T, const N: usize> core::ops::Not for Mask<T, N>
601576
where
602577
T: MaskElement,
603-
LaneCount<N>: SupportedLaneCount,
604578
{
605579
type Output = Mask<T, N>;
606580
#[inline]
@@ -612,7 +586,6 @@ where
612586
impl<T, const N: usize> core::ops::BitAndAssign for Mask<T, N>
613587
where
614588
T: MaskElement,
615-
LaneCount<N>: SupportedLaneCount,
616589
{
617590
#[inline]
618591
fn bitand_assign(&mut self, rhs: Self) {
@@ -623,7 +596,6 @@ where
623596
impl<T, const N: usize> core::ops::BitAndAssign<bool> for Mask<T, N>
624597
where
625598
T: MaskElement,
626-
LaneCount<N>: SupportedLaneCount,
627599
{
628600
#[inline]
629601
fn bitand_assign(&mut self, rhs: bool) {
@@ -634,7 +606,6 @@ where
634606
impl<T, const N: usize> core::ops::BitOrAssign for Mask<T, N>
635607
where
636608
T: MaskElement,
637-
LaneCount<N>: SupportedLaneCount,
638609
{
639610
#[inline]
640611
fn bitor_assign(&mut self, rhs: Self) {
@@ -645,7 +616,6 @@ where
645616
impl<T, const N: usize> core::ops::BitOrAssign<bool> for Mask<T, N>
646617
where
647618
T: MaskElement,
648-
LaneCount<N>: SupportedLaneCount,
649619
{
650620
#[inline]
651621
fn bitor_assign(&mut self, rhs: bool) {
@@ -656,7 +626,6 @@ where
656626
impl<T, const N: usize> core::ops::BitXorAssign for Mask<T, N>
657627
where
658628
T: MaskElement,
659-
LaneCount<N>: SupportedLaneCount,
660629
{
661630
#[inline]
662631
fn bitxor_assign(&mut self, rhs: Self) {
@@ -667,7 +636,6 @@ where
667636
impl<T, const N: usize> core::ops::BitXorAssign<bool> for Mask<T, N>
668637
where
669638
T: MaskElement,
670-
LaneCount<N>: SupportedLaneCount,
671639
{
672640
#[inline]
673641
fn bitxor_assign(&mut self, rhs: bool) {
@@ -679,8 +647,6 @@ macro_rules! impl_from {
679647
{ $from:ty => $($to:ty),* } => {
680648
$(
681649
impl<const N: usize> From<Mask<$from, N>> for Mask<$to, N>
682-
where
683-
LaneCount<N>: SupportedLaneCount,
684650
{
685651
#[inline]
686652
fn from(value: Mask<$from, N>) -> Self {

crates/core_simd/src/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mod alias;
55
mod cast;
66
mod fmt;
77
mod iter;
8-
mod lane_count;
98
mod masks;
109
mod ops;
1110
mod select;
@@ -27,7 +26,6 @@ pub mod simd {
2726

2827
pub use crate::core_simd::alias::*;
2928
pub use crate::core_simd::cast::*;
30-
pub use crate::core_simd::lane_count::{LaneCount, SupportedLaneCount};
3129
pub use crate::core_simd::masks::*;
3230
pub use crate::core_simd::select::*;
3331
pub use crate::core_simd::swizzle::*;

0 commit comments

Comments
 (0)