@@ -251,6 +251,9 @@ unsafe fn test_simd() {
251251 test_mm_add_epi8 ( ) ;
252252 test_mm_add_pd ( ) ;
253253 test_mm_cvtepi8_epi16 ( ) ;
254+ #[ cfg( not( jit) ) ]
255+ test_mm_cvtps_epi32 ( ) ;
256+ test_mm_cvttps_epi32 ( ) ;
254257 test_mm_cvtsi128_si64 ( ) ;
255258
256259 test_mm_extract_epi8 ( ) ;
@@ -476,6 +479,41 @@ unsafe fn test_mm256_permutevar8x32_epi32() {
476479 assert_eq_m256i ( r, e) ;
477480}
478481
482+ #[ cfg( target_arch = "x86_64" ) ]
483+ #[ target_feature( enable = "avx2" ) ]
484+ #[ cfg( not( jit) ) ]
485+ unsafe fn test_mm_cvtps_epi32 ( ) {
486+ let floats: [ f32 ; 4 ] = [ 1.5 , -2.5 , i32:: MAX as f32 + 1.0 , f32:: NAN ] ;
487+
488+ let float_vec = _mm_loadu_ps ( floats. as_ptr ( ) ) ;
489+ let int_vec = _mm_cvtps_epi32 ( float_vec) ;
490+
491+ let mut ints: [ i32 ; 4 ] = [ 0 ; 4 ] ;
492+ _mm_storeu_si128 ( ints. as_mut_ptr ( ) as * mut __m128i , int_vec) ;
493+
494+ // this is very different from `floats.map(|f| f as i32)`!
495+ let expected_ints: [ i32 ; 4 ] = [ 2 , -2 , i32:: MIN , i32:: MIN ] ;
496+
497+ assert_eq ! ( ints, expected_ints) ;
498+ }
499+
500+ #[ cfg( target_arch = "x86_64" ) ]
501+ #[ target_feature( enable = "avx2" ) ]
502+ unsafe fn test_mm_cvttps_epi32 ( ) {
503+ let floats: [ f32 ; 4 ] = [ 1.5 , -2.5 , i32:: MAX as f32 + 1.0 , f32:: NAN ] ;
504+
505+ let float_vec = _mm_loadu_ps ( floats. as_ptr ( ) ) ;
506+ let int_vec = _mm_cvttps_epi32 ( float_vec) ;
507+
508+ let mut ints: [ i32 ; 4 ] = [ 0 ; 4 ] ;
509+ _mm_storeu_si128 ( ints. as_mut_ptr ( ) as * mut __m128i , int_vec) ;
510+
511+ // this is very different from `floats.map(|f| f as i32)`!
512+ let expected_ints: [ i32 ; 4 ] = [ 1 , -2 , i32:: MIN , i32:: MIN ] ;
513+
514+ assert_eq ! ( ints, expected_ints) ;
515+ }
516+
479517fn test_checked_mul ( ) {
480518 let u: Option < u8 > = u8:: from_str_radix ( "1000" , 10 ) . ok ( ) ;
481519 assert_eq ! ( u, None ) ;
0 commit comments