Skip to content

Commit b81b3e5

Browse files
committed
Add vld1q_s32 and vld1q_u32
1 parent 1c378c3 commit b81b3e5

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,6 +1812,32 @@ pub unsafe fn vld1q_f32(addr: *const f32) -> float32x4_t {
18121812
))
18131813
}
18141814

1815+
#[inline]
1816+
#[target_feature(enable = "neon")]
1817+
#[cfg_attr(test, assert_instr(ldr))]
1818+
pub unsafe fn vld1q_s32(addr: *const i32) -> int32x4_t {
1819+
use crate::core_arch::simd::i32x4;
1820+
transmute(i32x4::new(
1821+
*addr,
1822+
*addr.offset(1),
1823+
*addr.offset(2),
1824+
*addr.offset(3),
1825+
))
1826+
}
1827+
1828+
#[inline]
1829+
#[target_feature(enable = "neon")]
1830+
#[cfg_attr(test, assert_instr(ldr))]
1831+
pub unsafe fn vld1q_u32(addr: *const u32) -> uint32x4_t {
1832+
use crate::core_arch::simd::u32x4;
1833+
transmute(u32x4::new(
1834+
*addr,
1835+
*addr.offset(1),
1836+
*addr.offset(2),
1837+
*addr.offset(3),
1838+
))
1839+
}
1840+
18151841
#[cfg(test)]
18161842
mod tests {
18171843
use crate::core_arch::aarch64::test_support::*;
@@ -1830,6 +1856,26 @@ mod tests {
18301856
assert_eq!(r, e);
18311857
}
18321858

1859+
#[simd_test(enable = "neon")]
1860+
unsafe fn test_vld1q_s32() {
1861+
let e = i32x4::new(1, 2, 3, 4);
1862+
let f = [0, 1, 2, 3, 4];
1863+
// do a load that has 4 byte alignment to make sure we're not
1864+
// over aligning it
1865+
let r: i32x4 = transmute(vld1q_s32(f[1..].as_ptr()));
1866+
assert_eq!(r, e);
1867+
}
1868+
1869+
#[simd_test(enable = "neon")]
1870+
unsafe fn test_vld1q_u32() {
1871+
let e = u32x4::new(1, 2, 3, 4);
1872+
let f = [0, 1, 2, 3, 4];
1873+
// do a load that has 4 byte alignment to make sure we're not
1874+
// over aligning it
1875+
let r: u32x4 = transmute(vld1q_u32(f[1..].as_ptr()));
1876+
assert_eq!(r, e);
1877+
}
1878+
18331879
#[simd_test(enable = "neon")]
18341880
unsafe fn test_vpaddq_s16() {
18351881
let a = i16x8::new(1, 2, 3, 4, 5, 6, 7, 8);

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ extern "C" {
219219
) -> int8x8_t;
220220
#[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v4f32.p0i8")]
221221
fn vld1q_v4f32(addr: *const u8, align: u32) -> float32x4_t;
222+
#[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1.v4i32.p0i8")]
223+
fn vld1q_v4i32(addr: *const u8, align: u32) -> int32x4_t;
222224
}
223225

224226
/// Absolute value (wrapping).
@@ -1769,6 +1771,26 @@ pub unsafe fn vld1q_u8(addr: *const u8) -> uint8x16_t {
17691771
ptr::read(addr as *const uint8x16_t)
17701772
}
17711773

1774+
/// Load multiple single-element structures to one, two, three, or four registers
1775+
#[inline]
1776+
#[cfg(target_arch = "arm")]
1777+
#[target_feature(enable = "neon")]
1778+
#[target_feature(enable = "v7")]
1779+
#[cfg_attr(test, assert_instr("vld1.32"))]
1780+
pub unsafe fn vld1q_s32(addr: *const i32) -> int32x4_t {
1781+
vld1q_v4i32(addr as *const u8, 4)
1782+
}
1783+
1784+
/// Load multiple single-element structures to one, two, three, or four registers
1785+
#[inline]
1786+
#[cfg(target_arch = "arm")]
1787+
#[target_feature(enable = "neon")]
1788+
#[target_feature(enable = "v7")]
1789+
#[cfg_attr(test, assert_instr("vld1.32"))]
1790+
pub unsafe fn vld1q_u32(addr: *const u32) -> uint32x4_t {
1791+
transmute(vld1q_v4i32(addr as *const u8, 4))
1792+
}
1793+
17721794
/// Load multiple single-element structures to one, two, three, or four registers
17731795
#[inline]
17741796
#[cfg(target_arch = "arm")]
@@ -1826,6 +1848,28 @@ mod tests {
18261848
assert_eq!(r, e);
18271849
}
18281850

1851+
#[cfg(target_arch = "arm")]
1852+
#[simd_test(enable = "neon")]
1853+
unsafe fn test_vld1q_s32() {
1854+
let e = i32x4::new(1, 2, 3, 4);
1855+
let f = [0, 1, 2, 3, 4];
1856+
// do a load that has 4 byte alignment to make sure we're not
1857+
// over aligning it
1858+
let r: i32x4 = transmute(vld1q_s32(f[1..].as_ptr()));
1859+
assert_eq!(r, e);
1860+
}
1861+
1862+
#[cfg(target_arch = "arm")]
1863+
#[simd_test(enable = "neon")]
1864+
unsafe fn test_vld1q_u32() {
1865+
let e = u32x4::new(1, 2, 3, 4);
1866+
let f = [0, 1, 2, 3, 4];
1867+
// do a load that has 4 byte alignment to make sure we're not
1868+
// over aligning it
1869+
let r: u32x4 = transmute(vld1q_u32(f[1..].as_ptr()));
1870+
assert_eq!(r, e);
1871+
}
1872+
18291873
#[simd_test(enable = "neon")]
18301874
unsafe fn test_vld1q_dup_f32() {
18311875
let e = f32x4::new(1., 1., 1., 1.);

0 commit comments

Comments
 (0)