Skip to content

Commit 1c378c3

Browse files
authored
Add vld1q_dup_f32 (#897)
1 parent 25dfd40 commit 1c378c3

File tree

1 file changed

+20
-0
lines changed
  • crates/core_arch/src/arm/neon

1 file changed

+20
-0
lines changed

crates/core_arch/src/arm/neon/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,18 @@ pub unsafe fn vld1q_f32(addr: *const f32) -> float32x4_t {
17791779
vld1q_v4f32(addr as *const u8, 4)
17801780
}
17811781

1782+
/// Load one single-element structure and Replicate to all lanes (of one register).
1783+
#[inline]
1784+
#[target_feature(enable = "neon")]
1785+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
1786+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vld1.32"))]
1787+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ld1r))]
1788+
pub unsafe fn vld1q_dup_f32(addr: *const f32) -> float32x4_t {
1789+
use crate::core_arch::simd::f32x4;
1790+
let v = *addr;
1791+
transmute(f32x4::new(v, v, v, v))
1792+
}
1793+
17821794
#[cfg(test)]
17831795
mod tests {
17841796
use super::*;
@@ -1814,6 +1826,14 @@ mod tests {
18141826
assert_eq!(r, e);
18151827
}
18161828

1829+
#[simd_test(enable = "neon")]
1830+
unsafe fn test_vld1q_dup_f32() {
1831+
let e = f32x4::new(1., 1., 1., 1.);
1832+
let f = [1., 2., 3., 4.];
1833+
let r: f32x4 = transmute(vld1q_dup_f32(f.as_ptr()));
1834+
assert_eq!(r, e);
1835+
}
1836+
18171837
#[simd_test(enable = "neon")]
18181838
unsafe fn test_vget_lane_u8() {
18191839
let v = i8x8::new(1, 2, 3, 4, 5, 6, 7, 8);

0 commit comments

Comments
 (0)