Add unsigned saturating add/sub intrinsics for aarch64

This commit is contained in:
Afonso Bordado 2023-11-04 19:37:36 +00:00
parent 88c2e7896b
commit 70a6abfd29
2 changed files with 27 additions and 2 deletions

View File

@ -180,6 +180,24 @@ unsafe fn test_vpadd_u8() {
assert_eq!(r, e); assert_eq!(r, e);
} }
#[cfg(target_arch = "aarch64")]
unsafe fn test_vqsub_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 0xff]);
let b = u8x8::from([30, 1, 1, 1, 34, 0xff, 36, 37]);
let r: u8x8 = transmute(vqsub_u8(transmute(a), transmute(b)));
let e = u8x8::from([0, 1, 2, 3, 0, 0, 0, 218]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vqadd_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 0xff]);
let b = u8x8::from([30, 1, 1, 1, 34, 0xff, 36, 37]);
let r: u8x8 = transmute(vqadd_u8(transmute(a), transmute(b)));
let e = u8x8::from([31, 3, 4, 5, 39, 0xff, 43, 0xff]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
fn main() { fn main() {
unsafe { unsafe {
@ -204,6 +222,9 @@ fn main() {
test_vpadd_u16(); test_vpadd_u16();
test_vpadd_u32(); test_vpadd_u32();
test_vpadd_u8(); test_vpadd_u8();
test_vqsub_u8();
test_vqadd_u8();
} }
} }

View File

@ -44,7 +44,9 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
}); });
} }
_ if intrinsic.starts_with("llvm.aarch64.neon.sqadd.v") => { _ if intrinsic.starts_with("llvm.aarch64.neon.sqadd.v")
|| intrinsic.starts_with("llvm.aarch64.neon.uqadd.v") =>
{
intrinsic_args!(fx, args => (x, y); intrinsic); intrinsic_args!(fx, args => (x, y); intrinsic);
simd_pair_for_each_lane_typed(fx, x, y, ret, &|fx, x_lane, y_lane| { simd_pair_for_each_lane_typed(fx, x, y, ret, &|fx, x_lane, y_lane| {
@ -52,7 +54,9 @@ pub(crate) fn codegen_aarch64_llvm_intrinsic_call<'tcx>(
}); });
} }
_ if intrinsic.starts_with("llvm.aarch64.neon.sqsub.v") => { _ if intrinsic.starts_with("llvm.aarch64.neon.sqsub.v")
|| intrinsic.starts_with("llvm.aarch64.neon.uqsub.v") =>
{
intrinsic_args!(fx, args => (x, y); intrinsic); intrinsic_args!(fx, args => (x, y); intrinsic);
simd_pair_for_each_lane_typed(fx, x, y, ret, &|fx, x_lane, y_lane| { simd_pair_for_each_lane_typed(fx, x, y, ret, &|fx, x_lane, y_lane| {