add neon instruction vget_high_* (#1074)
This commit is contained in:
parent
01c99c1d05
commit
25116fb1eb
2 changed files with 232 additions and 0 deletions
|
|
@ -1512,6 +1512,14 @@ pub unsafe fn vcombine_p64(low: poly64x1_t, high: poly64x1_t) -> poly64x2_t {
|
|||
simd_shuffle2(low, high, [0, 1])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(test, assert_instr(mov))]
|
||||
pub unsafe fn vget_high_f64(a: float64x2_t) -> float64x1_t {
|
||||
float64x1_t(simd_extract(a, 1))
|
||||
}
|
||||
|
||||
/* FIXME: 16-bit float
|
||||
/// Vector combine
|
||||
#[inline]
|
||||
|
|
@ -3467,6 +3475,14 @@ mod tests {
|
|||
test_vcombine!(test_vcombine_p64 => vcombine_p64([3_u64], [13_u64]));
|
||||
test_vcombine!(test_vcombine_f64 => vcombine_f64([-3_f64], [13_f64]));
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_f64() {
|
||||
let a = f64x2::new(1.0, 2.0);
|
||||
let e = f64x1::new(2.0);
|
||||
let r: f64x1 = transmute(vget_high_f64(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vceq_u64() {
|
||||
test_cmp_u64(
|
||||
|
|
|
|||
|
|
@ -3742,6 +3742,126 @@ pub unsafe fn vget_lane_u8<const IMM5: i32>(v: uint8x8_t) -> u8 {
|
|||
simd_extract(v, IMM5 as u32)
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_s8(a: int8x16_t) -> int8x8_t {
|
||||
simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_s16(a: int16x8_t) -> int16x4_t {
|
||||
simd_shuffle4(a, a, [4, 5, 6, 7])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_s32(a: int32x4_t) -> int32x2_t {
|
||||
simd_shuffle2(a, a, [2, 3])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_s64(a: int64x2_t) -> int64x1_t {
|
||||
int64x1_t(simd_extract(a, 1))
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_u8(a: uint8x16_t) -> uint8x8_t {
|
||||
simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_u16(a: uint16x8_t) -> uint16x4_t {
|
||||
simd_shuffle4(a, a, [4, 5, 6, 7])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_u32(a: uint32x4_t) -> uint32x2_t {
|
||||
simd_shuffle2(a, a, [2, 3])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_u64(a: uint64x2_t) -> uint64x1_t {
|
||||
uint64x1_t(simd_extract(a, 1))
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_p8(a: poly8x16_t) -> poly8x8_t {
|
||||
simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_p16(a: poly16x8_t) -> poly16x4_t {
|
||||
simd_shuffle4(a, a, [4, 5, 6, 7])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_p64(a: poly64x2_t) -> poly64x1_t {
|
||||
poly64x1_t(simd_extract(a, 1))
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
|
||||
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vmov"))]
|
||||
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(ext))]
|
||||
pub unsafe fn vget_high_f32(a: float32x4_t) -> float32x2_t {
|
||||
simd_shuffle2(a, a, [2, 3])
|
||||
}
|
||||
|
||||
/// Duplicate vector element to vector or scalar
|
||||
#[inline]
|
||||
#[target_feature(enable = "neon")]
|
||||
|
|
@ -5697,6 +5817,102 @@ mod tests {
|
|||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_s8() {
|
||||
let a = i8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let e = i8x8::new(9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let r: i8x8 = transmute(vget_high_s8(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_s16() {
|
||||
let a = i16x8::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let e = i16x4::new(5, 6, 7, 8);
|
||||
let r: i16x4 = transmute(vget_high_s16(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_s32() {
|
||||
let a = i32x4::new(1, 2, 3, 4);
|
||||
let e = i32x2::new(3, 4);
|
||||
let r: i32x2 = transmute(vget_high_s32(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_s64() {
|
||||
let a = i64x2::new(1, 2);
|
||||
let e = i64x1::new(2);
|
||||
let r: i64x1 = transmute(vget_high_s64(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_u8() {
|
||||
let a = u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let e = u8x8::new(9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let r: u8x8 = transmute(vget_high_s8(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_u16() {
|
||||
let a = u16x8::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let e = u16x4::new(5, 6, 7, 8);
|
||||
let r: u16x4 = transmute(vget_high_s16(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_u32() {
|
||||
let a = u32x4::new(1, 2, 3, 4);
|
||||
let e = u32x2::new(3, 4);
|
||||
let r: u32x2 = transmute(vget_high_s32(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_u64() {
|
||||
let a = u64x2::new(1, 2);
|
||||
let e = u64x1::new(2);
|
||||
let r: u64x1 = transmute(vget_high_s64(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_p8() {
|
||||
let a = u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let e = u8x8::new(9, 10, 11, 12, 13, 14, 15, 16);
|
||||
let r: u8x8 = transmute(vget_high_p8(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_p16() {
|
||||
let a = u16x8::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
let e = u16x4::new(5, 6, 7, 8);
|
||||
let r: u16x4 = transmute(vget_high_p16(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_p64() {
|
||||
let a = u64x2::new(1, 2);
|
||||
let e = u64x1::new(2);
|
||||
let r: u64x1 = transmute(vget_high_p64(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vget_high_f32() {
|
||||
let a = f32x4::new(1.0, 2.0, 3.0, 4.0);
|
||||
let e = f32x2::new(3.0, 4.0);
|
||||
let r: f32x2 = transmute(vget_high_f32(transmute(a)));
|
||||
assert_eq!(r, e);
|
||||
}
|
||||
|
||||
#[simd_test(enable = "neon")]
|
||||
unsafe fn test_vdupq_n_s8() {
|
||||
let v: i8 = 42;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue