@@ -135,6 +135,12 @@ extern "C" {
135
135
#[ cfg_attr( target_arch = "arm" , link_name = "llvm.arm.neon.vabs.v4i32" ) ]
136
136
#[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.abs.v4i32" ) ]
137
137
fn vabsq_s32_ ( a : int32x4_t ) -> int32x4_t ;
138
+ #[ cfg_attr( target_arch = "arm" , link_name = "llvm.fabs.v2f32" ) ]
139
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.fabs.v2f32" ) ]
140
+ fn vabs_f32_ ( a : float32x2_t ) -> float32x2_t ;
141
+ #[ cfg_attr( target_arch = "arm" , link_name = "llvm.fabs.v4f32" ) ]
142
+ #[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.fabs.v4f32" ) ]
143
+ fn vabsq_f32_ ( a : float32x4_t ) -> float32x4_t ;
138
144
139
145
#[ cfg_attr( target_arch = "arm" , link_name = "llvm.arm.neon.vrsqrte.v2f32" ) ]
140
146
#[ cfg_attr( target_arch = "aarch64" , link_name = "llvm.aarch64.neon.frsqrte.v2f32" ) ]
@@ -1147,6 +1153,24 @@ pub unsafe fn vabsq_s16(a: int16x8_t) -> int16x8_t {
1147
1153
pub unsafe fn vabsq_s32 ( a : int32x4_t ) -> int32x4_t {
1148
1154
vabsq_s32_ ( a)
1149
1155
}
1156
+ /// Floating-point absolute value.
1157
+ #[ inline]
1158
+ #[ target_feature( enable = "neon" ) ]
1159
+ #[ cfg_attr( target_arch = "arm" , target_feature( enable = "v7" ) ) ]
1160
+ #[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( fabs) ) ]
1161
+ #[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( fabs) ) ]
1162
+ pub unsafe fn vabs_f32 ( a : float32x2_t ) -> float32x2_t {
1163
+ vabs_f32_ ( a)
1164
+ }
1165
+ /// Floating-point absolute value.
1166
+ #[ inline]
1167
+ #[ target_feature( enable = "neon" ) ]
1168
+ #[ cfg_attr( target_arch = "arm" , target_feature( enable = "v7" ) ) ]
1169
+ #[ cfg_attr( all( test, target_arch = "arm" ) , assert_instr( fabs) ) ]
1170
+ #[ cfg_attr( all( test, target_arch = "aarch64" ) , assert_instr( fabs) ) ]
1171
+ pub unsafe fn vabsq_f32 ( a : float32x4_t ) -> float32x4_t {
1172
+ vabsq_f32_ ( a)
1173
+ }
1150
1174
1151
1175
/// Add pairwise.
1152
1176
#[ inline]
@@ -8565,6 +8589,20 @@ mod tests {
8565
8589
assert_eq ! ( r, e) ;
8566
8590
}
8567
8591
#[ simd_test( enable = "neon" ) ]
8592
+ unsafe fn test_vabs_f32 ( ) {
8593
+ let a = f32x2:: new ( f32:: MIN , -1.0 ) ;
8594
+ let r: f32x2 = transmute ( vabs_f32 ( transmute ( a) ) ) ;
8595
+ let e = f32x2:: new ( f32:: MAX , 1.0 ) ;
8596
+ assert_eq ! ( r, e) ;
8597
+ }
8598
+ #[ simd_test( enable = "neon" ) ]
8599
+ unsafe fn test_vabsq_f32 ( ) {
8600
+ let a = f32x4:: new ( f32:: MIN , -1.32 , -4.3 , -6.8 ) ;
8601
+ let r: f32x4 = transmute ( vabsq_f32 ( transmute ( a) ) ) ;
8602
+ let e = f32x4:: new ( f32:: MAX , 1.32 , 4.3 , 6.8 ) ;
8603
+ assert_eq ! ( r, e) ;
8604
+ }
8605
+ #[ simd_test( enable = "neon" ) ]
8568
8606
unsafe fn test_vpadd_s16 ( ) {
8569
8607
let a = i16x4:: new ( 1 , 2 , 3 , 4 ) ;
8570
8608
let b = i16x4:: new ( 0 , -1 , -2 , -3 ) ;
0 commit comments