Skip to content

Commit 594ff85

Browse files
authored
Add neon instruction vbslq (#1065)
1 parent d9ee7a4 commit 594ff85

File tree

2 files changed

+526
-0
lines changed

2 files changed

+526
-0
lines changed

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

+32
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,20 @@ pub unsafe fn vbsl_f64(a: uint64x1_t, b: float64x1_t, c: float64x1_t) -> float64
719719
pub unsafe fn vbsl_p64(a: poly64x1_t, b: poly64x1_t, c: poly64x1_t) -> poly64x1_t {
720720
simd_select(transmute::<_, int64x1_t>(a), b, c)
721721
}
722+
/// Bitwise Select. (128-bit)
723+
#[inline]
724+
#[target_feature(enable = "neon")]
725+
#[cfg_attr(test, assert_instr(bsl))]
726+
pub unsafe fn vbslq_f64(a: uint64x2_t, b: float64x2_t, c: float64x2_t) -> float64x2_t {
727+
simd_select(transmute::<_, int64x2_t>(a), b, c)
728+
}
729+
/// Bitwise Select. (128-bit)
730+
#[inline]
731+
#[target_feature(enable = "neon")]
732+
#[cfg_attr(test, assert_instr(bsl))]
733+
pub unsafe fn vbslq_p64(a: poly64x2_t, b: poly64x2_t, c: poly64x2_t) -> poly64x2_t {
734+
simd_select(transmute::<_, int64x2_t>(a), b, c)
735+
}
722736

723737
/// Signed saturating Accumulate of Unsigned value.
724738
#[inline]
@@ -3948,6 +3962,24 @@ mod tests {
39483962
let r: u64x1 = transmute(vbsl_p64(transmute(a), transmute(b), transmute(c)));
39493963
assert_eq!(r, e);
39503964
}
3965+
#[simd_test(enable = "neon")]
3966+
unsafe fn test_vbslq_f64() {
3967+
let a = u64x2::new(u64::MAX, 0);
3968+
let b = f64x2::new(f64::MAX, f64::MAX);
3969+
let c = f64x2::new(f64::MIN, f64::MIN);
3970+
let e = f64x2::new(f64::MAX, f64::MIN);
3971+
let r: f64x2 = transmute(vbslq_f64(transmute(a), transmute(b), transmute(c)));
3972+
assert_eq!(r, e);
3973+
}
3974+
#[simd_test(enable = "neon")]
3975+
unsafe fn test_vbslq_p64() {
3976+
let a = u64x2::new(u64::MAX, 0);
3977+
let b = u64x2::new(u64::MAX, u64::MAX);
3978+
let c = u64x2::new(u64::MIN, u64::MIN);
3979+
let e = u64x2::new(u64::MAX, u64::MIN);
3980+
let r: u64x2 = transmute(vbslq_p64(transmute(a), transmute(b), transmute(c)));
3981+
assert_eq!(r, e);
3982+
}
39513983

39523984
#[simd_test(enable = "neon")]
39533985
unsafe fn test_vaddv_s16() {

0 commit comments

Comments
 (0)