Skip to content

Commit f4fd7ef

Browse files
authored
Add missing vtst_p16 and vtstq_p16 intrinsics (#1257)
1 parent cfba59f commit f4fd7ef

File tree

3 files changed

+46
-2
lines changed

3 files changed

+46
-2
lines changed

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

+42
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,30 @@ pub unsafe fn vtstq_p8(a: poly8x16_t, b: poly8x16_t) -> uint8x16_t {
10321032
simd_ne(c, transmute(d))
10331033
}
10341034

1035+
/// Signed compare bitwise Test bits nonzero
1036+
#[inline]
1037+
#[target_feature(enable = "neon")]
1038+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
1039+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vtst))]
1040+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmtst))]
1041+
pub unsafe fn vtst_p16(a: poly16x4_t, b: poly16x4_t) -> uint16x4_t {
1042+
let c: poly16x4_t = simd_and(a, b);
1043+
let d: i16x4 = i16x4::new(0, 0, 0, 0);
1044+
simd_ne(c, transmute(d))
1045+
}
1046+
1047+
/// Signed compare bitwise Test bits nonzero
1048+
#[inline]
1049+
#[target_feature(enable = "neon")]
1050+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
1051+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vtst))]
1052+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(cmtst))]
1053+
pub unsafe fn vtstq_p16(a: poly16x8_t, b: poly16x8_t) -> uint16x8_t {
1054+
let c: poly16x8_t = simd_and(a, b);
1055+
let d: i16x8 = i16x8::new(0, 0, 0, 0, 0, 0, 0, 0);
1056+
simd_ne(c, transmute(d))
1057+
}
1058+
10351059
/// Unsigned compare bitwise Test bits nonzero
10361060
#[inline]
10371061
#[target_feature(enable = "neon")]
@@ -25039,6 +25063,24 @@ mod test {
2503925063
assert_eq!(r, e);
2504025064
}
2504125065

25066+
#[simd_test(enable = "neon")]
25067+
unsafe fn test_vtst_p16() {
25068+
let a: i16x4 = i16x4::new(-32768, 0x00, 0x01, 0x02);
25069+
let b: i16x4 = i16x4::new(-32768, 0x00, 0x01, 0x02);
25070+
let e: u16x4 = u16x4::new(0xFF_FF, 0, 0xFF_FF, 0xFF_FF);
25071+
let r: u16x4 = transmute(vtst_p16(transmute(a), transmute(b)));
25072+
assert_eq!(r, e);
25073+
}
25074+
25075+
#[simd_test(enable = "neon")]
25076+
unsafe fn test_vtstq_p16() {
25077+
let a: i16x8 = i16x8::new(-32768, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
25078+
let b: i16x8 = i16x8::new(-32768, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);
25079+
let e: u16x8 = u16x8::new(0xFF_FF, 0, 0xFF_FF, 0xFF_FF, 0xFF_FF, 0xFF_FF, 0xFF_FF, 0xFF_FF);
25080+
let r: u16x8 = transmute(vtstq_p16(transmute(a), transmute(b)));
25081+
assert_eq!(r, e);
25082+
}
25083+
2504225084
#[simd_test(enable = "neon")]
2504325085
unsafe fn test_vtst_u8() {
2504425086
let a: u8x8 = u8x8::new(0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06);

crates/stdarch-gen/neon.spec

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ aarch64 = cmtst
411411
generate int64x1_t:uint64x1_t, int64x2_t:uint64x2_t, poly64x1_t:uint64x1_t, poly64x2_t:uint64x2_t
412412

413413
arm = vtst
414-
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, poly8x8_t:uint8x8_t, poly8x16_t:uint8x16_t
414+
generate int8x8_t:uint8x8_t, int8x16_t:uint8x16_t, int16x4_t:uint16x4_t, int16x8_t:uint16x8_t, int32x2_t:uint32x2_t, int32x4_t:uint32x4_t, poly8x8_t:uint8x8_t, poly8x16_t:uint8x16_t, poly16x4_t:uint16x4_t, poly16x8_t:uint16x8_t
415415

416416
/// Unsigned compare bitwise Test bits nonzero
417417
name = vtst
@@ -7550,4 +7550,4 @@ n = 2
75507550
validate 510
75517551

75527552
aarch64 = sri
7553-
generate i64, u64
7553+
generate i64, u64

crates/stdarch-verify/tests/arm.rs

+2
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ fn verify_all_signatures() {
594594
"vclsq_u8",
595595
"vclsq_u16",
596596
"vclsq_u32",
597+
"vtst_p16",
598+
"vtstq_p16",
597599
"__dbg",
598600
];
599601
let arm = match map.get(rust.name) {

0 commit comments

Comments
 (0)