forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[neon] reciprocal square-root estimate (rust-lang#121)
- Loading branch information
1 parent
93cc250
commit b2028d5
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//! ARM NEON intrinsics | ||
//! | ||
//! The references is [ARM's NEON Intrinsics Reference](http://infocenter.arm.com/help/topic/com.arm.doc.ihi0073a/IHI0073A_arm_neon_intrinsics_ref.pdf). [ARM's NEON Intrinsics Online Database](https://developer.arm.com/technologies/neon/intrinsics) is also useful. | ||
#[cfg(test)] | ||
use stdsimd_test::assert_instr; | ||
|
||
use v64::{f32x2}; | ||
|
||
#[allow(improper_ctypes)] | ||
extern "C" { | ||
#[link_name = "llvm.aarch64.neon.frsqrte.v2f32"] | ||
fn frsqrte_v2f32(a: f32x2) -> f32x2; | ||
} | ||
|
||
/// Reciprocal square-root estimate. | ||
#[inline(always)] | ||
#[target_feature = "+neon"] | ||
#[cfg_attr(test, assert_instr(frsqrte))] | ||
pub unsafe fn vrsqrte_f32(a: f32x2) -> f32x2 { | ||
frsqrte_v2f32(a) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use stdsimd_test::simd_test; | ||
|
||
use v64::{f32x2}; | ||
use arm::neon; | ||
|
||
#[test] | ||
fn vrsqrt_f32() { | ||
let a = f32x2::new(1.0, 2.0); | ||
let e = f32x2::new(0.9980469, 0.7050781); | ||
let r = unsafe { neon::vrsqrte_f32(a) }; | ||
assert_eq!(r, e); | ||
} | ||
} |