@@ -1742,6 +1742,15 @@ pub unsafe fn _mm_cvtsd_si32(a: f64x2) -> i32 {
1742
1742
cvtsd2si ( a)
1743
1743
}
1744
1744
1745
+ /// Convert the lower double-precision (64-bit) floating-point element in a to a 64-bit integer.
1746
+ #[ cfg( target_arch = "x86_64" ) ]
1747
+ #[ inline( always) ]
1748
+ #[ target_feature = "+sse2" ]
1749
+ #[ cfg_attr( test, assert_instr( cvtsd2si) ) ]
1750
+ pub unsafe fn _mm_cvtsd_si64 ( a : f64x2 ) -> i64 {
1751
+ cvtsd2si64 ( a)
1752
+ }
1753
+
1745
1754
/// Convert the lower double-precision (64-bit) floating-point element in `b` to a
1746
1755
/// single-precision (32-bit) floating-point element, store the result in the lower element
1747
1756
/// of the return value, and copy the upper element from `a` to the upper element the return value.
@@ -1780,6 +1789,16 @@ pub unsafe fn _mm_cvttsd_si32(a: f64x2) -> i32 {
1780
1789
cvttsd2si ( a)
1781
1790
}
1782
1791
1792
+ /// Convert the lower double-precision (64-bit) floating-point element in `a` to a 64-bit integer
1793
+ /// with truncation.
1794
+ #[ cfg( target_arch = "x86_64" ) ]
1795
+ #[ inline( always) ]
1796
+ #[ target_feature = "+sse2" ]
1797
+ #[ cfg_attr( test, assert_instr( cvttsd2si) ) ]
1798
+ pub unsafe fn _mm_cvttsd_si64 ( a : f64x2 ) -> i64 {
1799
+ cvttsd2si64 ( a)
1800
+ }
1801
+
1783
1802
/// Convert packed single-precision (32-bit) floating-point elements in `a` to packed 32-bit
1784
1803
/// integers with truncation
1785
1804
#[ inline( always) ]
@@ -1976,6 +1995,8 @@ extern {
1976
1995
fn cvtpd2dq ( a : f64x2 ) -> i32x4 ;
1977
1996
#[ link_name = "llvm.x86.sse2.cvtsd2si" ]
1978
1997
fn cvtsd2si ( a : f64x2 ) -> i32 ;
1998
+ #[ link_name = "llvm.x86.sse2.cvtsd2si64" ]
1999
+ fn cvtsd2si64 ( a : f64x2 ) -> i64 ;
1979
2000
#[ link_name = "llvm.x86.sse2.cvtsd2ss" ]
1980
2001
fn cvtsd2ss ( a : f32x4 , b : f64x2 ) -> f32x4 ;
1981
2002
#[ link_name = "llvm.x86.sse2.cvtss2sd" ]
@@ -1984,6 +2005,8 @@ extern {
1984
2005
fn cvttpd2dq ( a : f64x2 ) -> i32x4 ;
1985
2006
#[ link_name = "llvm.x86.sse2.cvttsd2si" ]
1986
2007
fn cvttsd2si ( a : f64x2 ) -> i32 ;
2008
+ #[ link_name = "llvm.x86.sse2.cvttsd2si64" ]
2009
+ fn cvttsd2si64 ( a : f64x2 ) -> i64 ;
1987
2010
#[ link_name = "llvm.x86.sse2.cvttps2dq" ]
1988
2011
fn cvttps2dq ( a : f32x4 ) -> i32x4 ;
1989
2012
}
@@ -3562,6 +3585,21 @@ mod tests {
3562
3585
assert_eq ! ( r, i32 :: MIN ) ;
3563
3586
}
3564
3587
3588
+ #[ cfg( target_arch = "x86_64" ) ]
3589
+ #[ simd_test = "sse2" ]
3590
+ unsafe fn _mm_cvtsd_si64 ( ) {
3591
+ use std:: { f64, i64} ;
3592
+
3593
+ let r = sse2:: _mm_cvtsd_si64 ( f64x2:: new ( -2.0 , 5.0 ) ) ;
3594
+ assert_eq ! ( r, -2_i64 ) ;
3595
+
3596
+ let r = sse2:: _mm_cvtsd_si64 ( f64x2:: new ( f64:: MAX , f64:: MIN ) ) ;
3597
+ assert_eq ! ( r, i64 :: MIN ) ;
3598
+
3599
+ let r = sse2:: _mm_cvtsd_si64 ( f64x2:: new ( f64:: NAN , f64:: NAN ) ) ;
3600
+ assert_eq ! ( r, i64 :: MIN ) ;
3601
+ }
3602
+
3565
3603
#[ simd_test = "sse2" ]
3566
3604
unsafe fn _mm_cvtsd_ss ( ) {
3567
3605
use std:: { f64, f32} ;
@@ -3624,6 +3662,20 @@ mod tests {
3624
3662
assert_eq ! ( r, i32 :: MIN ) ;
3625
3663
}
3626
3664
3665
+ #[ cfg( target_arch = "x86_64" ) ]
3666
+ #[ simd_test = "sse2" ]
3667
+ unsafe fn _mm_cvttsd_si64 ( ) {
3668
+ use std:: { f64, i64} ;
3669
+
3670
+ let a = f64x2:: new ( -1.1 , 2.2 ) ;
3671
+ let r = sse2:: _mm_cvttsd_si64 ( a) ;
3672
+ assert_eq ! ( r, -1_i64 ) ;
3673
+
3674
+ let a = f64x2:: new ( f64:: NEG_INFINITY , f64:: NAN ) ;
3675
+ let r = sse2:: _mm_cvttsd_si64 ( a) ;
3676
+ assert_eq ! ( r, i64 :: MIN ) ;
3677
+ }
3678
+
3627
3679
#[ simd_test = "sse2" ]
3628
3680
unsafe fn _mm_cvttps_epi32 ( ) {
3629
3681
use std:: { f32, i32} ;
0 commit comments