@@ -1780,6 +1780,16 @@ pub unsafe fn _mm_cvttsd_si32(a: f64x2) -> i32 {
1780
1780
cvttsd2si ( a)
1781
1781
}
1782
1782
1783
+ /// Convert packed single-precision (32-bit) floating-point elements in `a` to packed 32-bit
1784
+ /// integers with truncation
1785
+ #[ inline( always) ]
1786
+ #[ target_feature = "+sse2" ]
1787
+ #[ cfg_attr( test, assert_instr( cvttps2dq) ) ]
1788
+ pub unsafe fn _mm_cvttps_epi32 ( a : f32x4 ) -> i32x4 {
1789
+ cvttps2dq ( a)
1790
+ }
1791
+
1792
+
1783
1793
/// Return a mask of the most significant bit of each element in `a`.
1784
1794
///
1785
1795
/// The mask is stored in the 2 least significant bits of the return value.
@@ -1967,6 +1977,8 @@ extern {
1967
1977
fn cvttpd2dq ( a : f64x2 ) -> i32x4 ;
1968
1978
#[ link_name = "llvm.x86.sse2.cvttsd2si" ]
1969
1979
fn cvttsd2si ( a : f64x2 ) -> i32 ;
1980
+ #[ link_name = "llvm.x86.sse2.cvttps2dq" ]
1981
+ fn cvttps2dq ( a : f32x4 ) -> i32x4 ;
1970
1982
}
1971
1983
1972
1984
#[ cfg( test) ]
@@ -3605,6 +3617,19 @@ mod tests {
3605
3617
assert_eq ! ( r, i32 :: MIN ) ;
3606
3618
}
3607
3619
3620
+ #[ simd_test = "sse2" ]
3621
+ unsafe fn _mm_cvttps_epi32 ( ) {
3622
+ use std:: { f32, i32} ;
3623
+
3624
+ let a = f32x4:: new ( -1.1 , 2.2 , -3.3 , 6.6 ) ;
3625
+ let r = sse2:: _mm_cvttps_epi32 ( a) ;
3626
+ assert_eq ! ( r, i32x4:: new( -1 , 2 , -3 , 6 ) ) ;
3627
+
3628
+ let a = f32x4:: new ( f32:: NEG_INFINITY , f32:: INFINITY , f32:: MIN , f32:: MAX ) ;
3629
+ let r = sse2:: _mm_cvttps_epi32 ( a) ;
3630
+ assert_eq ! ( r, i32x4:: new( i32 :: MIN , i32 :: MIN , i32 :: MIN , i32 :: MIN ) ) ;
3631
+ }
3632
+
3608
3633
#[ simd_test = "sse2" ]
3609
3634
unsafe fn _mm_load1_pd ( ) {
3610
3635
let d = -5.0 ;
0 commit comments