@@ -208,7 +208,7 @@ pub unsafe fn _mm_insert_epi64(a: i64x2, i: i64, imm8: u8) -> i64x2 {
208
208
a. replace ( ( imm8 & 0b1 ) as u32 , i)
209
209
}
210
210
211
- /// Compare packed 8-bit integers in `a` and `b`,87 and return packed maximum
211
+ /// Compare packed 8-bit integers in `a` and `b` and return packed maximum
212
212
/// values in dst.
213
213
#[ inline( always) ]
214
214
#[ target_feature = "+sse4.1" ]
@@ -244,6 +244,42 @@ pub unsafe fn _mm_max_epu32(a: u32x4, b: u32x4) -> u32x4 {
244
244
pmaxud ( a, b)
245
245
}
246
246
247
+ /// Compare packed 8-bit integers in `a` and `b` and return packed minimum
248
+ /// values in dst.
249
+ #[ inline( always) ]
250
+ #[ target_feature = "+sse4.1" ]
251
+ #[ cfg_attr( test, assert_instr( pminsb) ) ]
252
+ pub unsafe fn _mm_min_epi8 ( a : i8x16 , b : i8x16 ) -> i8x16 {
253
+ pminsb ( a, b)
254
+ }
255
+
256
+ /// Compare packed unsigned 16-bit integers in `a` and `b`, and return packed
257
+ /// minimum.
258
+ #[ inline( always) ]
259
+ #[ target_feature = "+sse4.1" ]
260
+ #[ cfg_attr( test, assert_instr( pminuw) ) ]
261
+ pub unsafe fn _mm_min_epu16 ( a : u16x8 , b : u16x8 ) -> u16x8 {
262
+ pminuw ( a, b)
263
+ }
264
+
265
+ /// Compare packed 32-bit integers in `a` and `b`, and return packed minimum
266
+ /// values.
267
+ #[ inline( always) ]
268
+ #[ target_feature = "+sse4.1" ]
269
+ #[ cfg_attr( test, assert_instr( pminsd) ) ]
270
+ pub unsafe fn _mm_min_epi32 ( a : i32x4 , b : i32x4 ) -> i32x4 {
271
+ pminsd ( a, b)
272
+ }
273
+
274
+ /// Compare packed unsigned 32-bit integers in `a` and `b`, and return packed
275
+ /// minimum values.
276
+ #[ inline( always) ]
277
+ #[ target_feature = "+sse4.1" ]
278
+ #[ cfg_attr( test, assert_instr( pminud) ) ]
279
+ pub unsafe fn _mm_min_epu32 ( a : u32x4 , b : u32x4 ) -> u32x4 {
280
+ pminud ( a, b)
281
+ }
282
+
247
283
/// Convert packed 32-bit integers from `a` and `b` to packed 16-bit integers
248
284
/// using unsigned saturation
249
285
#[ inline( always) ]
@@ -569,6 +605,14 @@ extern "C" {
569
605
fn pmaxsd ( a : i32x4 , b : i32x4 ) -> i32x4 ;
570
606
#[ link_name = "llvm.x86.sse41.pmaxud" ]
571
607
fn pmaxud ( a : u32x4 , b : u32x4 ) -> u32x4 ;
608
+ #[ link_name = "llvm.x86.sse41.pminsb" ]
609
+ fn pminsb ( a : i8x16 , b : i8x16 ) -> i8x16 ;
610
+ #[ link_name = "llvm.x86.sse41.pminuw" ]
611
+ fn pminuw ( a : u16x8 , b : u16x8 ) -> u16x8 ;
612
+ #[ link_name = "llvm.x86.sse41.pminsd" ]
613
+ fn pminsd ( a : i32x4 , b : i32x4 ) -> i32x4 ;
614
+ #[ link_name = "llvm.x86.sse41.pminud" ]
615
+ fn pminud ( a : u32x4 , b : u32x4 ) -> u32x4 ;
572
616
#[ link_name = "llvm.x86.sse41.packusdw" ]
573
617
fn packusdw ( a : i32x4 , b : i32x4 ) -> u16x8 ;
574
618
#[ link_name = "llvm.x86.sse41.dppd" ]
@@ -784,6 +828,84 @@ mod tests {
784
828
assert_eq ! ( r, e) ;
785
829
}
786
830
831
+ #[ simd_test = "sse4.1" ]
832
+ unsafe fn _mm_min_epi8_1 ( ) {
833
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
834
+ let a = i8x16:: new (
835
+ 1 , 4 , 5 , 8 , 9 , 12 , 13 , 16 ,
836
+ 17 , 20 , 21 , 24 , 25 , 28 , 29 , 32 ,
837
+ ) ;
838
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
839
+ let b = i8x16:: new (
840
+ 2 , 3 , 6 , 7 , 10 , 11 , 14 , 15 ,
841
+ 18 , 19 , 22 , 23 , 26 , 27 , 30 , 31 ,
842
+ ) ;
843
+ let r = sse41:: _mm_min_epi8 ( a, b) ;
844
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
845
+ let e = i8x16:: new (
846
+ 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 ,
847
+ 17 , 19 , 21 , 23 , 25 , 27 , 29 , 31 ,
848
+ ) ;
849
+ assert_eq ! ( r, e) ;
850
+ }
851
+
852
+ #[ simd_test = "sse4.1" ]
853
+ unsafe fn _mm_min_epi8_2 ( ) {
854
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
855
+ let a = i8x16:: new (
856
+ 1 , -4 , -5 , 8 , -9 , -12 , 13 , -16 ,
857
+ 17 , 20 , 21 , 24 , 25 , 28 , 29 , 32 ,
858
+ ) ;
859
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
860
+ let b = i8x16:: new (
861
+ 2 , -3 , -6 , 7 , -10 , -11 , 14 , -15 ,
862
+ 18 , 19 , 22 , 23 , 26 , 27 , 30 , 31 ,
863
+ ) ;
864
+ let r = sse41:: _mm_min_epi8 ( a, b) ;
865
+ #[ cfg_attr( rustfmt, rustfmt_skip) ]
866
+ let e = i8x16:: new (
867
+ 1 , -4 , -6 , 7 , -10 , -12 , 13 , -16 ,
868
+ 17 , 19 , 21 , 23 , 25 , 27 , 29 , 31 ,
869
+ ) ;
870
+ assert_eq ! ( r, e) ;
871
+ }
872
+
873
+ #[ simd_test = "sse4.1" ]
874
+ unsafe fn _mm_min_epu16 ( ) {
875
+ let a = u16x8:: new ( 1 , 4 , 5 , 8 , 9 , 12 , 13 , 16 ) ;
876
+ let b = u16x8:: new ( 2 , 3 , 6 , 7 , 10 , 11 , 14 , 15 ) ;
877
+ let r = sse41:: _mm_min_epu16 ( a, b) ;
878
+ let e = u16x8:: new ( 1 , 3 , 5 , 7 , 9 , 11 , 13 , 15 ) ;
879
+ assert_eq ! ( r, e) ;
880
+ }
881
+
882
+ #[ simd_test = "sse4.1" ]
883
+ unsafe fn _mm_min_epi32_1 ( ) {
884
+ let a = i32x4:: new ( 1 , 4 , 5 , 8 ) ;
885
+ let b = i32x4:: new ( 2 , 3 , 6 , 7 ) ;
886
+ let r = sse41:: _mm_min_epi32 ( a, b) ;
887
+ let e = i32x4:: new ( 1 , 3 , 5 , 7 ) ;
888
+ assert_eq ! ( r, e) ;
889
+ }
890
+
891
+ #[ simd_test = "sse4.1" ]
892
+ unsafe fn _mm_min_epi32_2 ( ) {
893
+ let a = i32x4:: new ( -1 , 4 , 5 , -7 ) ;
894
+ let b = i32x4:: new ( -2 , 3 , -6 , 8 ) ;
895
+ let r = sse41:: _mm_min_epi32 ( a, b) ;
896
+ let e = i32x4:: new ( -2 , 3 , -6 , -7 ) ;
897
+ assert_eq ! ( r, e) ;
898
+ }
899
+
900
+ #[ simd_test = "sse4.1" ]
901
+ unsafe fn _mm_min_epu32 ( ) {
902
+ let a = u32x4:: new ( 1 , 4 , 5 , 8 ) ;
903
+ let b = u32x4:: new ( 2 , 3 , 6 , 7 ) ;
904
+ let r = sse41:: _mm_min_epu32 ( a, b) ;
905
+ let e = u32x4:: new ( 1 , 3 , 5 , 7 ) ;
906
+ assert_eq ! ( r, e) ;
907
+ }
908
+
787
909
#[ simd_test = "sse4.1" ]
788
910
unsafe fn _mm_packus_epi32 ( ) {
789
911
let a = i32x4:: new ( 1 , 2 , 3 , 4 ) ;
0 commit comments