Skip to content

Commit

Permalink
Add vld1q_dup_f32 (rust-lang#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmuizel authored Sep 8, 2020
1 parent 25dfd40 commit 1c378c3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/core_arch/src/arm/neon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,18 @@ pub unsafe fn vld1q_f32(addr: *const f32) -> float32x4_t {
vld1q_v4f32(addr as *const u8, 4)
}

/// Load one single-element structure and Replicate to all lanes (of one register).
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ld1r))]
pub unsafe fn vld1q_dup_f32(addr: *const f32) -> float32x4_t {
use crate::core_arch::simd::f32x4;
let v = *addr;
transmute(f32x4::new(v, v, v, v))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down Expand Up @@ -1814,6 +1826,14 @@ mod tests {
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vld1q_dup_f32() {
let e = f32x4::new(1., 1., 1., 1.);
let f = [1., 2., 3., 4.];
let r: f32x4 = transmute(vld1q_dup_f32(f.as_ptr()));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vget_lane_u8() {
let v = i8x8::new(1, 2, 3, 4, 5, 6, 7, 8);
Expand Down

0 comments on commit 1c378c3

Please sign in to comment.