Skip to content

Commit b3cbdf1

Browse files
committed
add vshrq_n_u8 and vshlq_n_u8
1 parent 17d5811 commit b3cbdf1

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

crates/core_arch/src/arm/neon.rs

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,16 +1623,70 @@ pub unsafe fn vextq_s8(a: int8x16_t, b: int8x16_t, n: i32) -> int8x16_t {
16231623
}
16241624
}
16251625

1626+
//uint8x16_t vshrq_n_u8 (uint8x16_t a, const int n)
1627+
#[inline]
1628+
#[target_feature(enable = "neon")]
1629+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
1630+
#[cfg_attr(test, assert_instr(ushr))]
1631+
pub unsafe fn vshrq_n_u8(a: uint8x16_t, n: i32) -> uint8x16_t {
1632+
uint8x16_t(
1633+
a.0 >> n, a.1 >> n, a.2 >> n, a.3 >> n,
1634+
a.4 >> n, a.5 >> n, a.6 >> n, a.7 >> n,
1635+
a.8 >> n, a.9 >> n, a.10 >> n, a.11 >> n,
1636+
a.12 >> n, a.13 >> n, a.14 >> n, a.15 >> n
1637+
)
1638+
}
16261639

16271640

1641+
//uint8x16_t vshlq_n_u8 (uint8x16_t a, const int n)
1642+
#[inline]
1643+
#[target_feature(enable = "neon")]
1644+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
1645+
#[cfg_attr(test, assert_instr(ushl))]
1646+
pub unsafe fn vshlq_n_u8(a: uint8x16_t, n: i32) -> uint8x16_t {
1647+
uint8x16_t(
1648+
a.0 << n, a.1 << n, a.2 << n, a.3 << n,
1649+
a.4 << n, a.5 << n, a.6 << n, a.7 << n,
1650+
a.8 << n, a.9 << n, a.10 << n, a.11 << n,
1651+
a.12 << n, a.13 << n, a.14 << n, a.15 << n
1652+
)
1653+
}
1654+
16281655
#[cfg(test)]
16291656
mod tests {
16301657
use crate::core_arch::{arm::*, simd::*};
16311658
use std::{i16, i32, i8, mem::transmute, u16, u32, u8};
16321659
use stdarch_test::simd_test;
16331660

1661+
#[simd_test(enable = "neon")]
1662+
unsafe fn test_vshrq_n_u8() {
1663+
let a = u8x16::new(
1664+
1, 2, 3, 4,
1665+
5, 6, 7, 8,
1666+
9, 10, 11, 12,
1667+
13, 14, 15, 16
1668+
);
1669+
let e = u8x16::new(
1670+
0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4
1671+
);
1672+
let r: u8x16 = transmute(vshrq_n_u8(transmute(a), 2));
1673+
assert_eq!(r, e);
1674+
}
16341675

1635-
//uint8x16_t vqsubq_u8 (uint8x16_t a, uint8x16_t b)
1676+
#[simd_test(enable = "neon")]
1677+
unsafe fn test_vshlq_n_u8() {
1678+
let a = u8x16::new(
1679+
1, 2, 3, 4,
1680+
5, 6, 7, 8,
1681+
9, 10, 11, 12,
1682+
13, 14, 15, 16
1683+
);
1684+
let e = u8x16::new(
1685+
4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64
1686+
);
1687+
let r: u8x16 = transmute(vshlq_n_u8(transmute(a), 2));
1688+
assert_eq!(r, e);
1689+
}
16361690

16371691
#[simd_test(enable = "neon")]
16381692
unsafe fn test_vqsubq_u8() {
@@ -1657,6 +1711,7 @@ mod tests {
16571711
let r: u8x16 = transmute(vqsubq_u8(transmute(a), transmute(b)));
16581712
assert_eq!(r, e);
16591713
}
1714+
16601715
#[simd_test(enable = "neon")]
16611716
unsafe fn test_vqmovn_u64() {
16621717
let a = u64x2::new(1, 2);
@@ -3107,7 +3162,6 @@ mod tests {
31073162
assert_eq!(r, c);
31083163
}
31093164

3110-
31113165
#[simd_test(enable = "neon")]
31123166
unsafe fn test_vcle_f32() {
31133167
let a = f32x2::new(0.1, 2.3);

0 commit comments

Comments
 (0)