2
2
3
3
#![ allow( non_camel_case_types) ]
4
4
5
+ trait SimdLookup < const N : usize > {
6
+ type Vector ;
7
+ }
8
+ macro_rules! as_signed {
9
+ ( i8 ) => { i8 } ;
10
+ ( i16 ) => { i16 } ;
11
+ ( i32 ) => { i32 } ;
12
+ ( i64 ) => { i64 } ;
13
+ ( i128 ) => { i128 } ;
14
+
15
+ ( u8 ) => { i8 } ;
16
+ ( u16 ) => { i16 } ;
17
+ ( u32 ) => { i32 } ;
18
+ ( u64 ) => { i64 } ;
19
+ ( u128 ) => { i128 } ;
20
+
21
+ ( f8) => { i8 } ;
22
+ ( f16) => { i16 } ;
23
+ ( f32 ) => { i32 } ;
24
+ ( f64 ) => { i64 } ;
25
+ ( f128) => { i128 } ;
26
+ }
27
+
5
28
macro_rules! simd_ty {
6
- ( $id: ident [ $elem_type: ty ; $len: literal] : $( $param_name: ident) ,* ) => {
29
+ ( $id: ident [ $elem_type: ident ; $len: literal] : $( $param_name: ident) ,* ) => {
7
30
#[ repr( simd) ]
8
31
#[ derive( Copy , Clone ) ]
9
32
pub ( crate ) struct $id( [ $elem_type; $len] ) ;
@@ -55,7 +78,11 @@ macro_rules! simd_ty {
55
78
56
79
impl core:: cmp:: PartialEq for $id {
57
80
fn eq( & self , other: & Self ) -> bool {
58
- self . as_array( ) == other. as_array( )
81
+ type Mask = <as_signed!( $elem_type) as SimdLookup <$len>>:: Vector ;
82
+ unsafe {
83
+ let mask = core:: intrinsics:: simd:: simd_eq:: <Self , Mask >( * self , * other) ;
84
+ core:: intrinsics:: simd:: simd_reduce_all( mask)
85
+ }
59
86
}
60
87
}
61
88
@@ -65,6 +92,10 @@ macro_rules! simd_ty {
65
92
debug_simd_finish( f, stringify!( $id) , self . as_array( ) )
66
93
}
67
94
}
95
+
96
+ impl SimdLookup <$len> for $elem_type {
97
+ type Vector = $id;
98
+ }
68
99
}
69
100
}
70
101
@@ -109,12 +140,6 @@ macro_rules! simd_m_ty {
109
140
}
110
141
}
111
142
112
- impl core:: cmp:: PartialEq for $id {
113
- fn eq( & self , other: & Self ) -> bool {
114
- self . as_array( ) == other. as_array( )
115
- }
116
- }
117
-
118
143
impl core:: fmt:: Debug for $id {
119
144
#[ inline]
120
145
fn fmt( & self , f: & mut core:: fmt:: Formatter <' _>) -> core:: fmt:: Result {
@@ -865,6 +890,73 @@ simd_ty!(
865
890
) ;
866
891
867
892
// 1024-bit wide types:
893
+ simd_ty ! (
894
+ i16x64[ i16 ; 64 ] :
895
+ x0,
896
+ x1,
897
+ x2,
898
+ x3,
899
+ x4,
900
+ x5,
901
+ x6,
902
+ x7,
903
+ x8,
904
+ x9,
905
+ x10,
906
+ x11,
907
+ x12,
908
+ x13,
909
+ x14,
910
+ x15,
911
+ x16,
912
+ x17,
913
+ x18,
914
+ x19,
915
+ x20,
916
+ x21,
917
+ x22,
918
+ x23,
919
+ x24,
920
+ x25,
921
+ x26,
922
+ x27,
923
+ x28,
924
+ x29,
925
+ x30,
926
+ x31,
927
+ x32,
928
+ x33,
929
+ x34,
930
+ x35,
931
+ x36,
932
+ x37,
933
+ x38,
934
+ x39,
935
+ x40,
936
+ x41,
937
+ x42,
938
+ x43,
939
+ x44,
940
+ x45,
941
+ x46,
942
+ x47,
943
+ x48,
944
+ x49,
945
+ x50,
946
+ x51,
947
+ x52,
948
+ x53,
949
+ x54,
950
+ x55,
951
+ x56,
952
+ x57,
953
+ x58,
954
+ x59,
955
+ x60,
956
+ x61,
957
+ x62,
958
+ x63
959
+ ) ;
868
960
simd_ty ! (
869
961
u16x64[ u16 ; 64 ] :
870
962
x0,
0 commit comments