@@ -320,6 +320,17 @@ pub unsafe fn _mm_cmpnge_ss(a: f32x4, b: f32x4) -> f32x4 {
320
320
simd_shuffle4 ( a, cmpss ( b, a, 6 ) , [ 4 , 1 , 2 , 3 ] )
321
321
}
322
322
323
+ /// Check if the lowest `f32` of both inputs are ordered. The lowest 32 bits of
324
+ /// the result will be `0xffffffff` if neither of `a.extract(0)` or
325
+ /// `b.extract(0)` is a NaN, or `0` otherwise. The upper 96 bits of the result
326
+ /// are the upper 96 bits of `a`.
327
+ #[ inline( always) ]
328
+ #[ target_feature = "+sse" ]
329
+ #[ cfg_attr( test, assert_instr( cmpordss) ) ]
330
+ pub unsafe fn _mm_cmpord_ss ( a : f32x4 , b : f32x4 ) -> f32x4 {
331
+ cmpss ( a, b, 7 )
332
+ }
333
+
323
334
/// Construct a `f32x4` with the lowest element set to `a` and the rest set to
324
335
/// zero.
325
336
#[ inline( always) ]
@@ -1522,6 +1533,36 @@ mod tests {
1522
1533
assert_eq ! ( rd, ed) ;
1523
1534
}
1524
1535
1536
+ #[ simd_test = "sse" ]
1537
+ unsafe fn _mm_cmpord_ss ( ) {
1538
+ // TODO: This test is exactly the same as for _mm_cmplt_ss, but there
1539
+ // must be a difference. It may have to do with behavior in the presence
1540
+ // of NaNs (signaling or quiet). If so, we should add tests for those.
1541
+ use std:: mem:: transmute;
1542
+ use std:: f32:: NAN ;
1543
+
1544
+ let a = f32x4:: new ( 1.0 , 2.0 , 3.0 , 4.0 ) ;
1545
+ let b = f32x4:: new ( 0.0 , 5.0 , 6.0 , 7.0 ) ;
1546
+ let c = f32x4:: new ( NAN , 5.0 , 6.0 , 7.0 ) ;
1547
+ let d = f32x4:: new ( 2.0 , 5.0 , 6.0 , 7.0 ) ;
1548
+
1549
+ let b1 = !0u32 ; // a.extract(0) ord b.extract(0)
1550
+ let c1 = 0u32 ; // a.extract(0) ord c.extract(0)
1551
+ let d1 = !0u32 ; // a.extract(0) ord d.extract(0)
1552
+
1553
+ let rb: u32x4 = transmute ( sse:: _mm_cmpord_ss ( a, b) ) ;
1554
+ let eb: u32x4 = transmute ( f32x4:: new ( transmute ( b1) , 2.0 , 3.0 , 4.0 ) ) ;
1555
+ assert_eq ! ( rb, eb) ;
1556
+
1557
+ let rc: u32x4 = transmute ( sse:: _mm_cmpord_ss ( a, c) ) ;
1558
+ let ec: u32x4 = transmute ( f32x4:: new ( transmute ( c1) , 2.0 , 3.0 , 4.0 ) ) ;
1559
+ assert_eq ! ( rc, ec) ;
1560
+
1561
+ let rd: u32x4 = transmute ( sse:: _mm_cmpord_ss ( a, d) ) ;
1562
+ let ed: u32x4 = transmute ( f32x4:: new ( transmute ( d1) , 2.0 , 3.0 , 4.0 ) ) ;
1563
+ assert_eq ! ( rd, ed) ;
1564
+ }
1565
+
1525
1566
#[ simd_test = "sse" ]
1526
1567
unsafe fn _mm_set_ss ( ) {
1527
1568
let r = sse:: _mm_set_ss ( black_box ( 4.25 ) ) ;
0 commit comments