@@ -95,24 +95,6 @@ pub enum Shuffle {
95
95
ABDC ,
96
96
}
97
97
98
- macro_rules! lane_shuffle {
99
- { $l0: expr, $l1: expr, $l2: expr, $l3: expr, $l4: expr, $l5: expr, $l6: expr, $l7: expr, $x: expr} => {
100
- unsafe {
101
- use core:: arch:: aarch64:: vgetq_lane_u32;
102
- const c: [ i32 ; 8 ] = [ $l0, $l1, $l2, $l3, $l4, $l5, $l6, $l7] ;
103
- ( u32x4:: new( if c[ 0 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 0 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 0 ] - 4 ) } ,
104
- if c[ 1 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 1 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 1 ] - 4 ) } ,
105
- if c[ 2 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 2 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 2 ] - 4 ) } ,
106
- if c[ 3 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 3 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 3 ] - 4 ) } ) ,
107
- u32x4:: new( if c[ 4 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 4 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 4 ] - 4 ) } ,
108
- if c[ 5 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 5 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 5 ] - 4 ) } ,
109
- if c[ 6 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 6 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 6 ] - 4 ) } ,
110
- if c[ 7 ] < 4 { vgetq_lane_u32( $x. 0 . into_bits( ) , c[ 7 ] ) } else { vgetq_lane_u32( $x. 1 . into_bits( ) , c[ 7 ] - 4 ) } ) )
111
- }
112
-
113
- }
114
- }
115
-
116
98
#[ derive( Clone , Copy , Debug ) ]
117
99
pub struct FieldElement2625x4 ( pub ( crate ) [ ( u32x4 , u32x4 ) ; 5 ] ) ;
118
100
@@ -183,17 +165,18 @@ impl FieldElement2625x4 {
183
165
pub fn shuffle ( & self , control : Shuffle ) -> FieldElement2625x4 {
184
166
#[ inline( always) ]
185
167
fn shuffle_lanes ( x : ( u32x4 , u32x4 ) , control : Shuffle ) -> ( u32x4 , u32x4 ) {
168
+ use packed_simd:: shuffle;
186
169
match control {
187
- Shuffle :: AAAA => lane_shuffle ! ( 0 , 0 , 2 , 2 , 0 , 0 , 2 , 2 , x ) ,
188
- Shuffle :: BBBB => lane_shuffle ! ( 1 , 1 , 3 , 3 , 1 , 1 , 3 , 3 , x ) ,
189
- Shuffle :: CACA => lane_shuffle ! ( 4 , 0 , 6 , 2 , 4 , 0 , 6 , 2 , x ) ,
190
- Shuffle :: DBBD => lane_shuffle ! ( 5 , 1 , 7 , 3 , 1 , 5 , 3 , 7 , x ) ,
191
- Shuffle :: ADDA => lane_shuffle ! ( 0 , 5 , 2 , 7 , 5 , 0 , 7 , 2 , x ) ,
192
- Shuffle :: CBCB => lane_shuffle ! ( 4 , 1 , 6 , 3 , 4 , 1 , 6 , 3 , x ) ,
193
- Shuffle :: ABAB => lane_shuffle ! ( 0 , 1 , 2 , 3 , 0 , 1 , 2 , 3 , x ) ,
194
- Shuffle :: BADC => lane_shuffle ! ( 1 , 0 , 3 , 2 , 5 , 4 , 7 , 6 , x ) ,
195
- Shuffle :: BACD => lane_shuffle ! ( 1 , 0 , 3 , 2 , 4 , 5 , 6 , 7 , x ) ,
196
- Shuffle :: ABDC => lane_shuffle ! ( 0 , 1 , 2 , 3 , 5 , 4 , 7 , 6 , x ) ,
170
+ Shuffle :: AAAA => ( shuffle ! ( x . 0 , x . 1 , [ 0 , 0 , 2 , 2 ] ) , shuffle ! ( x . 0 , x . 1 , [ 0 , 0 , 2 , 2 ] ) ) ,
171
+ Shuffle :: BBBB => ( shuffle ! ( x . 0 , x . 1 , [ 1 , 1 , 3 , 3 ] ) , shuffle ! ( x . 0 , x . 1 , [ 1 , 1 , 3 , 3 ] ) ) ,
172
+ Shuffle :: CACA => ( shuffle ! ( x . 0 , x . 1 , [ 4 , 0 , 6 , 2 ] ) , shuffle ! ( x . 0 , x . 1 , [ 4 , 0 , 6 , 2 ] ) ) ,
173
+ Shuffle :: DBBD => ( shuffle ! ( x . 0 , x . 1 , [ 5 , 1 , 7 , 3 ] ) , shuffle ! ( x . 0 , x . 1 , [ 1 , 5 , 3 , 7 ] ) ) ,
174
+ Shuffle :: ADDA => ( shuffle ! ( x . 0 , x . 1 , [ 0 , 5 , 2 , 7 ] ) , shuffle ! ( x . 0 , x . 1 , [ 5 , 0 , 7 , 2 ] ) ) ,
175
+ Shuffle :: CBCB => ( shuffle ! ( x . 0 , x . 1 , [ 4 , 1 , 6 , 3 ] ) , shuffle ! ( x . 0 , x . 1 , [ 4 , 1 , 6 , 3 ] ) ) ,
176
+ Shuffle :: ABAB => ( shuffle ! ( x . 0 , x . 1 , [ 0 , 1 , 2 , 3 ] ) , shuffle ! ( x . 0 , x . 1 , [ 0 , 1 , 2 , 3 ] ) ) ,
177
+ Shuffle :: BADC => ( shuffle ! ( x . 0 , x . 1 , [ 1 , 0 , 3 , 2 ] ) , shuffle ! ( x . 0 , x . 1 , [ 5 , 4 , 7 , 6 ] ) ) ,
178
+ Shuffle :: BACD => ( shuffle ! ( x . 0 , x . 1 , [ 1 , 0 , 3 , 2 ] ) , shuffle ! ( x . 0 , x . 1 , [ 4 , 5 , 6 , 7 ] ) ) ,
179
+ Shuffle :: ABDC => ( shuffle ! ( x . 0 , x . 1 , [ 0 , 1 , 2 , 3 ] ) , shuffle ! ( x . 0 , x . 1 , [ 5 , 4 , 7 , 6 ] ) ) ,
197
180
}
198
181
}
199
182
0 commit comments