@@ -297,6 +297,58 @@ pub unsafe fn vsubq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
297
297
simd_sub ( a, b)
298
298
}
299
299
300
+ /// Maximum (vector)
301
+ #[ inline]
302
+ #[ target_feature( enable = "neon" ) ]
303
+ #[ cfg_attr( test, assert_instr( fmax) ) ]
304
+ pub unsafe fn vmax_f64 ( a : float64x1_t , b : float64x1_t ) -> float64x1_t {
305
+ #[ allow( improper_ctypes) ]
306
+ extern "C" {
307
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.fmax.v1f64" ) ]
308
+ fn vmax_f64_ ( a : float64x1_t , a : float64x1_t ) -> float64x1_t ;
309
+ }
310
+ vmax_f64_ ( a, b)
311
+ }
312
+
313
+ /// Maximum (vector)
314
+ #[ inline]
315
+ #[ target_feature( enable = "neon" ) ]
316
+ #[ cfg_attr( test, assert_instr( fmax) ) ]
317
+ pub unsafe fn vmaxq_f64 ( a : float64x2_t , b : float64x2_t ) -> float64x2_t {
318
+ #[ allow( improper_ctypes) ]
319
+ extern "C" {
320
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.fmax.v2f64" ) ]
321
+ fn vmaxq_f64_ ( a : float64x2_t , a : float64x2_t ) -> float64x2_t ;
322
+ }
323
+ vmaxq_f64_ ( a, b)
324
+ }
325
+
326
+ /// Minimum (vector)
327
+ #[ inline]
328
+ #[ target_feature( enable = "neon" ) ]
329
+ #[ cfg_attr( test, assert_instr( fmin) ) ]
330
+ pub unsafe fn vmin_f64 ( a : float64x1_t , b : float64x1_t ) -> float64x1_t {
331
+ #[ allow( improper_ctypes) ]
332
+ extern "C" {
333
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.fmin.v1f64" ) ]
334
+ fn vmin_f64_ ( a : float64x1_t , a : float64x1_t ) -> float64x1_t ;
335
+ }
336
+ vmin_f64_ ( a, b)
337
+ }
338
+
339
+ /// Minimum (vector)
340
+ #[ inline]
341
+ #[ target_feature( enable = "neon" ) ]
342
+ #[ cfg_attr( test, assert_instr( fmin) ) ]
343
+ pub unsafe fn vminq_f64 ( a : float64x2_t , b : float64x2_t ) -> float64x2_t {
344
+ #[ allow( improper_ctypes) ]
345
+ extern "C" {
346
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.fmin.v2f64" ) ]
347
+ fn vminq_f64_ ( a : float64x2_t , a : float64x2_t ) -> float64x2_t ;
348
+ }
349
+ vminq_f64_ ( a, b)
350
+ }
351
+
300
352
#[ cfg( test) ]
301
353
mod test {
302
354
use super :: * ;
@@ -663,4 +715,40 @@ mod test {
663
715
let r: f64x2 = transmute ( vsubq_f64 ( transmute ( a) , transmute ( b) ) ) ;
664
716
assert_eq ! ( r, e) ;
665
717
}
718
+
719
+ #[ simd_test( enable = "neon" ) ]
720
+ unsafe fn test_vmax_f64 ( ) {
721
+ let a: f64 = 1.0 ;
722
+ let b: f64 = 0.0 ;
723
+ let e: f64 = 1.0 ;
724
+ let r: f64 = transmute ( vmax_f64 ( transmute ( a) , transmute ( b) ) ) ;
725
+ assert_eq ! ( r, e) ;
726
+ }
727
+
728
+ #[ simd_test( enable = "neon" ) ]
729
+ unsafe fn test_vmaxq_f64 ( ) {
730
+ let a: f64x2 = f64x2:: new ( 1.0 , -2.0 ) ;
731
+ let b: f64x2 = f64x2:: new ( 0.0 , 3.0 ) ;
732
+ let e: f64x2 = f64x2:: new ( 1.0 , 3.0 ) ;
733
+ let r: f64x2 = transmute ( vmaxq_f64 ( transmute ( a) , transmute ( b) ) ) ;
734
+ assert_eq ! ( r, e) ;
735
+ }
736
+
737
+ #[ simd_test( enable = "neon" ) ]
738
+ unsafe fn test_vmin_f64 ( ) {
739
+ let a: f64 = 1.0 ;
740
+ let b: f64 = 0.0 ;
741
+ let e: f64 = 0.0 ;
742
+ let r: f64 = transmute ( vmin_f64 ( transmute ( a) , transmute ( b) ) ) ;
743
+ assert_eq ! ( r, e) ;
744
+ }
745
+
746
+ #[ simd_test( enable = "neon" ) ]
747
+ unsafe fn test_vminq_f64 ( ) {
748
+ let a: f64x2 = f64x2:: new ( 1.0 , -2.0 ) ;
749
+ let b: f64x2 = f64x2:: new ( 0.0 , 3.0 ) ;
750
+ let e: f64x2 = f64x2:: new ( 0.0 , -2.0 ) ;
751
+ let r: f64x2 = transmute ( vminq_f64 ( transmute ( a) , transmute ( b) ) ) ;
752
+ assert_eq ! ( r, e) ;
753
+ }
666
754
}
0 commit comments