@@ -5,8 +5,8 @@ use rustc_span::Symbol;
55use rustc_target:: callconv:: FnAbi ;
66
77use super :: {
8- ShiftOp , horizontal_bin_op, int_abs , mask_load, mask_store, mpsadbw, packssdw, packsswb,
9- packusdw , packuswb, pmulhrsw, psign, shift_simd_by_scalar, shift_simd_by_simd,
8+ ShiftOp , horizontal_bin_op, mask_load, mask_store, mpsadbw, packssdw, packsswb, packusdw ,
9+ packuswb, pmulhrsw, psign, shift_simd_by_scalar, shift_simd_by_simd,
1010} ;
1111use crate :: * ;
1212
@@ -25,24 +25,15 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2525 let unprefixed_name = link_name. as_str ( ) . strip_prefix ( "llvm.x86.avx2." ) . unwrap ( ) ;
2626
2727 match unprefixed_name {
28- // Used to implement the _mm256_abs_epi{8,16,32} functions.
29- // Calculates the absolute value of packed 8/16/32-bit integers.
30- "pabs.b" | "pabs.w" | "pabs.d" => {
31- let [ op] = this. check_shim_sig_lenient ( abi, CanonAbi :: C , link_name, args) ?;
32-
33- int_abs ( this, op, dest) ?;
34- }
35- // Used to implement the _mm256_h{add,adds,sub}_epi{16,32} functions.
36- // Horizontally add / add with saturation / subtract adjacent 16/32-bit
28+ // Used to implement the _mm256_h{adds,subs}_epi16 functions.
29+ // Horizontally add / subtract with saturation adjacent 16-bit
3730 // integer values in `left` and `right`.
38- "phadd.w" | "phadd. sw" | "phadd.d" | " phsub.w" | "phsub.sw" | "phsub.d " => {
31+ "phadd.sw" | "phsub.sw " => {
3932 let [ left, right] =
4033 this. check_shim_sig_lenient ( abi, CanonAbi :: C , link_name, args) ?;
4134
4235 let ( which, saturating) = match unprefixed_name {
43- "phadd.w" | "phadd.d" => ( mir:: BinOp :: Add , false ) ,
4436 "phadd.sw" => ( mir:: BinOp :: Add , true ) ,
45- "phsub.w" | "phsub.d" => ( mir:: BinOp :: Sub , false ) ,
4637 "phsub.sw" => ( mir:: BinOp :: Sub , true ) ,
4738 _ => unreachable ! ( ) ,
4839 } ;
@@ -110,42 +101,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
110101 this. write_scalar ( Scalar :: from_int ( 0 , dest. layout . size ) , & dest) ?;
111102 }
112103 }
113- // Used to implement the _mm256_madd_epi16 function.
114- // Multiplies packed signed 16-bit integers in `left` and `right`, producing
115- // intermediate signed 32-bit integers. Horizontally add adjacent pairs of
116- // intermediate 32-bit integers, and pack the results in `dest`.
117- "pmadd.wd" => {
118- let [ left, right] =
119- this. check_shim_sig_lenient ( abi, CanonAbi :: C , link_name, args) ?;
120-
121- let ( left, left_len) = this. project_to_simd ( left) ?;
122- let ( right, right_len) = this. project_to_simd ( right) ?;
123- let ( dest, dest_len) = this. project_to_simd ( dest) ?;
124-
125- assert_eq ! ( left_len, right_len) ;
126- assert_eq ! ( dest_len. strict_mul( 2 ) , left_len) ;
127-
128- for i in 0 ..dest_len {
129- let j1 = i. strict_mul ( 2 ) ;
130- let left1 = this. read_scalar ( & this. project_index ( & left, j1) ?) ?. to_i16 ( ) ?;
131- let right1 = this. read_scalar ( & this. project_index ( & right, j1) ?) ?. to_i16 ( ) ?;
132-
133- let j2 = j1. strict_add ( 1 ) ;
134- let left2 = this. read_scalar ( & this. project_index ( & left, j2) ?) ?. to_i16 ( ) ?;
135- let right2 = this. read_scalar ( & this. project_index ( & right, j2) ?) ?. to_i16 ( ) ?;
136-
137- let dest = this. project_index ( & dest, i) ?;
138-
139- // Multiplications are i16*i16->i32, which will not overflow.
140- let mul1 = i32:: from ( left1) . strict_mul ( right1. into ( ) ) ;
141- let mul2 = i32:: from ( left2) . strict_mul ( right2. into ( ) ) ;
142- // However, this addition can overflow in the most extreme case
143- // (-0x8000)*(-0x8000)+(-0x8000)*(-0x8000) = 0x80000000
144- let res = mul1. wrapping_add ( mul2) ;
145-
146- this. write_scalar ( Scalar :: from_i32 ( res) , & dest) ?;
147- }
148- }
149104 // Used to implement the _mm256_maddubs_epi16 function.
150105 // Multiplies packed 8-bit unsigned integers from `left` and packed
151106 // signed 8-bit integers from `right` into 16-bit signed integers. Then,
@@ -285,39 +240,6 @@ pub(super) trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
285240 this. copy_op ( & left, & dest) ?;
286241 }
287242 }
288- // Used to implement the _mm256_permute2x128_si256 function.
289- // Shuffles 128-bit blocks of `a` and `b` using `imm` as pattern.
290- "vperm2i128" => {
291- let [ left, right, imm] =
292- this. check_shim_sig_lenient ( abi, CanonAbi :: C , link_name, args) ?;
293-
294- assert_eq ! ( left. layout. size. bits( ) , 256 ) ;
295- assert_eq ! ( right. layout. size. bits( ) , 256 ) ;
296- assert_eq ! ( dest. layout. size. bits( ) , 256 ) ;
297-
298- // Transmute to `[i128; 2]`
299-
300- let array_layout =
301- this. layout_of ( Ty :: new_array ( this. tcx . tcx , this. tcx . types . i128 , 2 ) ) ?;
302- let left = left. transmute ( array_layout, this) ?;
303- let right = right. transmute ( array_layout, this) ?;
304- let dest = dest. transmute ( array_layout, this) ?;
305-
306- let imm = this. read_scalar ( imm) ?. to_u8 ( ) ?;
307-
308- for i in 0 ..2 {
309- let dest = this. project_index ( & dest, i) ?;
310- let src = match ( imm >> i. strict_mul ( 4 ) ) & 0b11 {
311- 0 => this. project_index ( & left, 0 ) ?,
312- 1 => this. project_index ( & left, 1 ) ?,
313- 2 => this. project_index ( & right, 0 ) ?,
314- 3 => this. project_index ( & right, 1 ) ?,
315- _ => unreachable ! ( ) ,
316- } ;
317-
318- this. copy_op ( & src, & dest) ?;
319- }
320- }
321243 // Used to implement the _mm256_sad_epu8 function.
322244 // Compute the absolute differences of packed unsigned 8-bit integers
323245 // in `left` and `right`, then horizontally sum each consecutive 8
0 commit comments