Skip to content

Commit

Permalink
Add ARM Neon vmnv_p8/vmvnq_p8 bw not intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaibaum authored and gnzlbg committed Jul 15, 2019
1 parent 11fb4c3 commit 8cb42c9
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions crates/core_arch/src/arm/neon.rs
Expand Up @@ -674,6 +674,30 @@ pub unsafe fn vmvnq_u32(a: uint32x4_t) -> uint32x4_t {
simd_xor(a, b)
}

/// Vector bitwise not.
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
pub unsafe fn vmvn_p8(a: poly8x8_t) -> poly8x8_t {
let b = poly8x8_t(255, 255, 255, 255, 255, 255, 255, 255);
simd_xor(a, b)
}

/// Vector bitwise not.
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
pub unsafe fn vmvnq_p8(a: poly8x16_t) -> poly8x16_t {
let b = poly8x16_t(
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
);
simd_xor(a, b)
}

/// Folding minimum of adjacent pairs
#[inline]
#[target_feature(enable = "neon")]
Expand Down Expand Up @@ -1406,6 +1430,24 @@ mod tests {
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vmvn_p8() {
let a = u8x8::new(0, 1, 2, 3, 4, 5, 6, 7);
let e = u8x8::new(255, 254, 253, 252, 251, 250, 249, 248);
let r: u8x8 = transmute(vmvn_p8(transmute(a)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vmvnq_p8() {
let a = u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
let e = u8x16::new(
255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
);
let r: u8x16 = transmute(vmvnq_p8(transmute(a)));
assert_eq!(r, e);
}

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

0 comments on commit 8cb42c9

Please sign in to comment.