Skip to content

Commit f3a8e45

Browse files
authored
support neon instruction vabdl_* and vabdl_high_* (rust-lang#1100)
1 parent 5f50363 commit f3a8e45

File tree

3 files changed

+366
-0
lines changed

3 files changed

+366
-0
lines changed

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

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,69 @@ pub unsafe fn vabdq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
3535
vabdq_f64_(a, b)
3636
}
3737

38+
/// Unsigned Absolute difference Long
39+
#[inline]
40+
#[target_feature(enable = "neon")]
41+
#[cfg_attr(test, assert_instr(uabdl))]
42+
pub unsafe fn vabdl_high_u8(a: uint8x16_t, b: uint8x16_t) -> uint16x8_t {
43+
let c: uint8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
44+
let d: uint8x8_t = simd_shuffle8(b, b, [8, 9, 10, 11, 12, 13, 14, 15]);
45+
simd_cast(vabd_u8(c, d))
46+
}
47+
48+
/// Unsigned Absolute difference Long
49+
#[inline]
50+
#[target_feature(enable = "neon")]
51+
#[cfg_attr(test, assert_instr(uabdl))]
52+
pub unsafe fn vabdl_high_u16(a: uint16x8_t, b: uint16x8_t) -> uint32x4_t {
53+
let c: uint16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
54+
let d: uint16x4_t = simd_shuffle4(b, b, [4, 5, 6, 7]);
55+
simd_cast(vabd_u16(c, d))
56+
}
57+
58+
/// Unsigned Absolute difference Long
59+
#[inline]
60+
#[target_feature(enable = "neon")]
61+
#[cfg_attr(test, assert_instr(uabdl))]
62+
pub unsafe fn vabdl_high_u32(a: uint32x4_t, b: uint32x4_t) -> uint64x2_t {
63+
let c: uint32x2_t = simd_shuffle2(a, a, [2, 3]);
64+
let d: uint32x2_t = simd_shuffle2(b, b, [2, 3]);
65+
simd_cast(vabd_u32(c, d))
66+
}
67+
68+
/// Signed Absolute difference Long
69+
#[inline]
70+
#[target_feature(enable = "neon")]
71+
#[cfg_attr(test, assert_instr(sabdl))]
72+
pub unsafe fn vabdl_high_s8(a: int8x16_t, b: int8x16_t) -> int16x8_t {
73+
let c: int8x8_t = simd_shuffle8(a, a, [8, 9, 10, 11, 12, 13, 14, 15]);
74+
let d: int8x8_t = simd_shuffle8(b, b, [8, 9, 10, 11, 12, 13, 14, 15]);
75+
let e: uint8x8_t = simd_cast(vabd_s8(c, d));
76+
simd_cast(e)
77+
}
78+
79+
/// Signed Absolute difference Long
80+
#[inline]
81+
#[target_feature(enable = "neon")]
82+
#[cfg_attr(test, assert_instr(sabdl))]
83+
pub unsafe fn vabdl_high_s16(a: int16x8_t, b: int16x8_t) -> int32x4_t {
84+
let c: int16x4_t = simd_shuffle4(a, a, [4, 5, 6, 7]);
85+
let d: int16x4_t = simd_shuffle4(b, b, [4, 5, 6, 7]);
86+
let e: uint16x4_t = simd_cast(vabd_s16(c, d));
87+
simd_cast(e)
88+
}
89+
90+
/// Signed Absolute difference Long
91+
#[inline]
92+
#[target_feature(enable = "neon")]
93+
#[cfg_attr(test, assert_instr(sabdl))]
94+
pub unsafe fn vabdl_high_s32(a: int32x4_t, b: int32x4_t) -> int64x2_t {
95+
let c: int32x2_t = simd_shuffle2(a, a, [2, 3]);
96+
let d: int32x2_t = simd_shuffle2(b, b, [2, 3]);
97+
let e: uint32x2_t = simd_cast(vabd_s32(c, d));
98+
simd_cast(e)
99+
}
100+
38101
/// Compare bitwise Equal (vector)
39102
#[inline]
40103
#[target_feature(enable = "neon")]
@@ -2879,6 +2942,60 @@ mod test {
28792942
assert_eq!(r, e);
28802943
}
28812944

2945+
#[simd_test(enable = "neon")]
2946+
unsafe fn test_vabdl_high_u8() {
2947+
let a: u8x16 = u8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
2948+
let b: u8x16 = u8x16::new(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10);
2949+
let e: u16x8 = u16x8::new(1, 0, 1, 2, 3, 4, 5, 6);
2950+
let r: u16x8 = transmute(vabdl_high_u8(transmute(a), transmute(b)));
2951+
assert_eq!(r, e);
2952+
}
2953+
2954+
#[simd_test(enable = "neon")]
2955+
unsafe fn test_vabdl_high_u16() {
2956+
let a: u16x8 = u16x8::new(1, 2, 3, 4, 8, 9, 11, 12);
2957+
let b: u16x8 = u16x8::new(10, 10, 10, 10, 10, 10, 10, 10);
2958+
let e: u32x4 = u32x4::new(2, 1, 1, 2);
2959+
let r: u32x4 = transmute(vabdl_high_u16(transmute(a), transmute(b)));
2960+
assert_eq!(r, e);
2961+
}
2962+
2963+
#[simd_test(enable = "neon")]
2964+
unsafe fn test_vabdl_high_u32() {
2965+
let a: u32x4 = u32x4::new(1, 2, 3, 4);
2966+
let b: u32x4 = u32x4::new(10, 10, 10, 10);
2967+
let e: u64x2 = u64x2::new(7, 6);
2968+
let r: u64x2 = transmute(vabdl_high_u32(transmute(a), transmute(b)));
2969+
assert_eq!(r, e);
2970+
}
2971+
2972+
#[simd_test(enable = "neon")]
2973+
unsafe fn test_vabdl_high_s8() {
2974+
let a: i8x16 = i8x16::new(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
2975+
let b: i8x16 = i8x16::new(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10);
2976+
let e: i16x8 = i16x8::new(1, 0, 1, 2, 3, 4, 5, 6);
2977+
let r: i16x8 = transmute(vabdl_high_s8(transmute(a), transmute(b)));
2978+
assert_eq!(r, e);
2979+
}
2980+
2981+
#[simd_test(enable = "neon")]
2982+
unsafe fn test_vabdl_high_s16() {
2983+
let a: i16x8 = i16x8::new(1, 2, 3, 4, 9, 10, 11, 12);
2984+
let b: i16x8 = i16x8::new(10, 10, 10, 10, 10, 10, 10, 10);
2985+
let e: i32x4 = i32x4::new(1, 0, 1, 2);
2986+
let r: i32x4 = transmute(vabdl_high_s16(transmute(a), transmute(b)));
2987+
assert_eq!(r, e);
2988+
}
2989+
2990+
#[simd_test(enable = "neon")]
2991+
unsafe fn test_vabdl_high_s32() {
2992+
let a: i32x4 = i32x4::new(1, 2, 3, 4);
2993+
let b: i32x4 = i32x4::new(10, 10, 10, 10);
2994+
let e: i64x2 = i64x2::new(7, 6);
2995+
let r: i64x2 = transmute(vabdl_high_s32(transmute(a), transmute(b)));
2996+
assert_eq!(r, e);
2997+
}
2998+
28822999
#[simd_test(enable = "neon")]
28833000
unsafe fn test_vceq_u64() {
28843001
let a: u64x1 = u64x1::new(0);

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

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,69 @@ pub unsafe fn vabdq_f32(a: float32x4_t, b: float32x4_t) -> float32x4_t {
713713
vabdq_f32_(a, b)
714714
}
715715

716+
/// Unsigned Absolute difference Long
717+
#[inline]
718+
#[target_feature(enable = "neon")]
719+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
720+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u8"))]
721+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
722+
pub unsafe fn vabdl_u8(a: uint8x8_t, b: uint8x8_t) -> uint16x8_t {
723+
simd_cast(vabd_u8(a, b))
724+
}
725+
726+
/// Unsigned Absolute difference Long
727+
#[inline]
728+
#[target_feature(enable = "neon")]
729+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
730+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u16"))]
731+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
732+
pub unsafe fn vabdl_u16(a: uint16x4_t, b: uint16x4_t) -> uint32x4_t {
733+
simd_cast(vabd_u16(a, b))
734+
}
735+
736+
/// Unsigned Absolute difference Long
737+
#[inline]
738+
#[target_feature(enable = "neon")]
739+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
740+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.u32"))]
741+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(uabdl))]
742+
pub unsafe fn vabdl_u32(a: uint32x2_t, b: uint32x2_t) -> uint64x2_t {
743+
simd_cast(vabd_u32(a, b))
744+
}
745+
746+
/// Signed Absolute difference Long
747+
#[inline]
748+
#[target_feature(enable = "neon")]
749+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
750+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s8"))]
751+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
752+
pub unsafe fn vabdl_s8(a: int8x8_t, b: int8x8_t) -> int16x8_t {
753+
let c: uint8x8_t = simd_cast(vabd_s8(a, b));
754+
simd_cast(c)
755+
}
756+
757+
/// Signed Absolute difference Long
758+
#[inline]
759+
#[target_feature(enable = "neon")]
760+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
761+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s16"))]
762+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
763+
pub unsafe fn vabdl_s16(a: int16x4_t, b: int16x4_t) -> int32x4_t {
764+
let c: uint16x4_t = simd_cast(vabd_s16(a, b));
765+
simd_cast(c)
766+
}
767+
768+
/// Signed Absolute difference Long
769+
#[inline]
770+
#[target_feature(enable = "neon")]
771+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
772+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr("vabdl.s32"))]
773+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(sabdl))]
774+
pub unsafe fn vabdl_s32(a: int32x2_t, b: int32x2_t) -> int64x2_t {
775+
let c: uint32x2_t = simd_cast(vabd_s32(a, b));
776+
simd_cast(c)
777+
}
778+
716779
/// Compare bitwise Equal (vector)
717780
#[inline]
718781
#[target_feature(enable = "neon")]
@@ -5320,6 +5383,60 @@ mod test {
53205383
assert_eq!(r, e);
53215384
}
53225385

5386+
#[simd_test(enable = "neon")]
5387+
unsafe fn test_vabdl_u8() {
5388+
let a: u8x8 = u8x8::new(1, 2, 3, 4, 4, 3, 2, 1);
5389+
let b: u8x8 = u8x8::new(10, 10, 10, 10, 10, 10, 10, 10);
5390+
let e: u16x8 = u16x8::new(9, 8, 7, 6, 6, 7, 8, 9);
5391+
let r: u16x8 = transmute(vabdl_u8(transmute(a), transmute(b)));
5392+
assert_eq!(r, e);
5393+
}
5394+
5395+
#[simd_test(enable = "neon")]
5396+
unsafe fn test_vabdl_u16() {
5397+
let a: u16x4 = u16x4::new(1, 2, 3, 4);
5398+
let b: u16x4 = u16x4::new(10, 10, 10, 10);
5399+
let e: u32x4 = u32x4::new(9, 8, 7, 6);
5400+
let r: u32x4 = transmute(vabdl_u16(transmute(a), transmute(b)));
5401+
assert_eq!(r, e);
5402+
}
5403+
5404+
#[simd_test(enable = "neon")]
5405+
unsafe fn test_vabdl_u32() {
5406+
let a: u32x2 = u32x2::new(1, 2);
5407+
let b: u32x2 = u32x2::new(10, 10);
5408+
let e: u64x2 = u64x2::new(9, 8);
5409+
let r: u64x2 = transmute(vabdl_u32(transmute(a), transmute(b)));
5410+
assert_eq!(r, e);
5411+
}
5412+
5413+
#[simd_test(enable = "neon")]
5414+
unsafe fn test_vabdl_s8() {
5415+
let a: i8x8 = i8x8::new(1, 2, 3, 4, 4, 3, 2, 1);
5416+
let b: i8x8 = i8x8::new(10, 10, 10, 10, 10, 10, 10, 10);
5417+
let e: i16x8 = i16x8::new(9, 8, 7, 6, 6, 7, 8, 9);
5418+
let r: i16x8 = transmute(vabdl_s8(transmute(a), transmute(b)));
5419+
assert_eq!(r, e);
5420+
}
5421+
5422+
#[simd_test(enable = "neon")]
5423+
unsafe fn test_vabdl_s16() {
5424+
let a: i16x4 = i16x4::new(1, 2, 11, 12);
5425+
let b: i16x4 = i16x4::new(10, 10, 10, 10);
5426+
let e: i32x4 = i32x4::new(9, 8, 1, 2);
5427+
let r: i32x4 = transmute(vabdl_s16(transmute(a), transmute(b)));
5428+
assert_eq!(r, e);
5429+
}
5430+
5431+
#[simd_test(enable = "neon")]
5432+
unsafe fn test_vabdl_s32() {
5433+
let a: i32x2 = i32x2::new(1, 11);
5434+
let b: i32x2 = i32x2::new(10, 10);
5435+
let e: i64x2 = i64x2::new(9, 1);
5436+
let r: i64x2 = transmute(vabdl_s32(transmute(a), transmute(b)));
5437+
assert_eq!(r, e);
5438+
}
5439+
53235440
#[simd_test(enable = "neon")]
53245441
unsafe fn test_vceq_u8() {
53255442
let a: u8x8 = u8x8::new(0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);

0 commit comments

Comments
 (0)