Skip to content

support neon instruction vabdl_* and vabdl_high_* #1100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions crates/core_arch/src/aarch64/neon/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,69 @@ pub unsafe fn vabdq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
vabdq_f64_(a, b)
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(uabdl))]
pub unsafe fn vabdl_high_u8(a: uint8x16_t, b: uint8x16_t) -> uint16x8_t {
let c: uint8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
let d: uint8x8_t = simd_shuffle8(b, b, [8, 9, 10, 11, 12, 13, 14, 15]);
simd_cast(vabd_u8(c, d))
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(uabdl))]
pub unsafe fn vabdl_high_u16(a: uint16x8_t, b: uint16x8_t) -> uint32x4_t {
let c: uint16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
let d: uint16x4_t = simd_shuffle4(b, b, [4, 5, 6, 7]);
simd_cast(vabd_u16(c, d))
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(uabdl))]
pub unsafe fn vabdl_high_u32(a: uint32x4_t, b: uint32x4_t) -> uint64x2_t {
let c: uint32x2_t = simd_shuffle2(a, a, [2, 3]);
let d: uint32x2_t = simd_shuffle2(b, b, [2, 3]);
simd_cast(vabd_u32(c, d))
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(sabdl))]
pub unsafe fn vabdl_high_s8(a: int8x16_t, b: int8x16_t) -> int16x8_t {
let c: int8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
let d: int8x8_t = simd_shuffle8(b, b, [8, 9, 10, 11, 12, 13, 14, 15]);
let e: uint8x8_t = simd_cast(vabd_s8(c, d));
simd_cast(e)
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(sabdl))]
pub unsafe fn vabdl_high_s16(a: int16x8_t, b: int16x8_t) -> int32x4_t {
let c: int16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
let d: int16x4_t = simd_shuffle4(b, b, [4, 5, 6, 7]);
let e: uint16x4_t = simd_cast(vabd_s16(c, d));
simd_cast(e)
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(test, assert_instr(sabdl))]
pub unsafe fn vabdl_high_s32(a: int32x4_t, b: int32x4_t) -> int64x2_t {
let c: int32x2_t = simd_shuffle2(a, a, [2, 3]);
let d: int32x2_t = simd_shuffle2(b, b, [2, 3]);
let e: uint32x2_t = simd_cast(vabd_s32(c, d));
simd_cast(e)
}

/// Compare bitwise Equal (vector)
#[inline]
#[target_feature(enable = "neon")]
Expand Down Expand Up @@ -2879,6 +2942,60 @@ mod test {
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_u8() {
let a: u8x16 = u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let b: u8x16 = u8x16::new(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10);
let e: u16x8 = u16x8::new(1, 0, 1, 2, 3, 4, 5, 6);
let r: u16x8 = transmute(vabdl_high_u8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_u16() {
let a: u16x8 = u16x8::new(1, 2, 3, 4, 8, 9, 11, 12);
let b: u16x8 = u16x8::new(10, 10, 10, 10, 10, 10, 10, 10);
let e: u32x4 = u32x4::new(2, 1, 1, 2);
let r: u32x4 = transmute(vabdl_high_u16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_u32() {
let a: u32x4 = u32x4::new(1, 2, 3, 4);
let b: u32x4 = u32x4::new(10, 10, 10, 10);
let e: u64x2 = u64x2::new(7, 6);
let r: u64x2 = transmute(vabdl_high_u32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_s8() {
let a: i8x16 = i8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
let b: i8x16 = i8x16::new(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10);
let e: i16x8 = i16x8::new(1, 0, 1, 2, 3, 4, 5, 6);
let r: i16x8 = transmute(vabdl_high_s8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_s16() {
let a: i16x8 = i16x8::new(1, 2, 3, 4, 9, 10, 11, 12);
let b: i16x8 = i16x8::new(10, 10, 10, 10, 10, 10, 10, 10);
let e: i32x4 = i32x4::new(1, 0, 1, 2);
let r: i32x4 = transmute(vabdl_high_s16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_high_s32() {
let a: i32x4 = i32x4::new(1, 2, 3, 4);
let b: i32x4 = i32x4::new(10, 10, 10, 10);
let e: i64x2 = i64x2::new(7, 6);
let r: i64x2 = transmute(vabdl_high_s32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vceq_u64() {
let a: u64x1 = u64x1::new(0);
Expand Down
117 changes: 117 additions & 0 deletions crates/core_arch/src/arm/neon/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,69 @@ pub unsafe fn vabdq_f32(a: float32x4_t, b: float32x4_t) -> float32x4_t {
vabdq_f32_(a, b)
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u8"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
pub unsafe fn vabdl_u8(a: uint8x8_t, b: uint8x8_t) -> uint16x8_t {
simd_cast(vabd_u8(a, b))
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u16"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
pub unsafe fn vabdl_u16(a: uint16x4_t, b: uint16x4_t) -> uint32x4_t {
simd_cast(vabd_u16(a, b))
}

/// Unsigned Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u32"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
pub unsafe fn vabdl_u32(a: uint32x2_t, b: uint32x2_t) -> uint64x2_t {
simd_cast(vabd_u32(a, b))
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s8"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
pub unsafe fn vabdl_s8(a: int8x8_t, b: int8x8_t) -> int16x8_t {
let c: uint8x8_t = simd_cast(vabd_s8(a, b));
simd_cast(c)
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s16"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
pub unsafe fn vabdl_s16(a: int16x4_t, b: int16x4_t) -> int32x4_t {
let c: uint16x4_t = simd_cast(vabd_s16(a, b));
simd_cast(c)
}

/// Signed Absolute difference Long
#[inline]
#[target_feature(enable = "neon")]
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s32"))]
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
pub unsafe fn vabdl_s32(a: int32x2_t, b: int32x2_t) -> int64x2_t {
let c: uint32x2_t = simd_cast(vabd_s32(a, b));
simd_cast(c)
}

/// Compare bitwise Equal (vector)
#[inline]
#[target_feature(enable = "neon")]
Expand Down Expand Up @@ -5320,6 +5383,60 @@ mod test {
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_u8() {
let a: u8x8 = u8x8::new(1, 2, 3, 4, 4, 3, 2, 1);
let b: u8x8 = u8x8::new(10, 10, 10, 10, 10, 10, 10, 10);
let e: u16x8 = u16x8::new(9, 8, 7, 6, 6, 7, 8, 9);
let r: u16x8 = transmute(vabdl_u8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_u16() {
let a: u16x4 = u16x4::new(1, 2, 3, 4);
let b: u16x4 = u16x4::new(10, 10, 10, 10);
let e: u32x4 = u32x4::new(9, 8, 7, 6);
let r: u32x4 = transmute(vabdl_u16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_u32() {
let a: u32x2 = u32x2::new(1, 2);
let b: u32x2 = u32x2::new(10, 10);
let e: u64x2 = u64x2::new(9, 8);
let r: u64x2 = transmute(vabdl_u32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_s8() {
let a: i8x8 = i8x8::new(1, 2, 3, 4, 4, 3, 2, 1);
let b: i8x8 = i8x8::new(10, 10, 10, 10, 10, 10, 10, 10);
let e: i16x8 = i16x8::new(9, 8, 7, 6, 6, 7, 8, 9);
let r: i16x8 = transmute(vabdl_s8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_s16() {
let a: i16x4 = i16x4::new(1, 2, 11, 12);
let b: i16x4 = i16x4::new(10, 10, 10, 10);
let e: i32x4 = i32x4::new(9, 8, 1, 2);
let r: i32x4 = transmute(vabdl_s16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vabdl_s32() {
let a: i32x2 = i32x2::new(1, 11);
let b: i32x2 = i32x2::new(10, 10);
let e: i64x2 = i64x2::new(9, 1);
let r: i64x2 = transmute(vabdl_s32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[simd_test(enable = "neon")]
unsafe fn test_vceq_u8() {
let a: u8x8 = u8x8::new(0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
Expand Down
Loading