Skip to content

Commit 11fb4c3

Browse files
jmaibaumgnzlbg
authored andcommitted
Add ARM Neon vmvn_*/vmvnq_* bitwise not intrinsics
1 parent a440c37 commit 11fb4c3

File tree

1 file changed

+240
-0
lines changed

1 file changed

+240
-0
lines changed

crates/core_arch/src/arm/neon.rs

+240
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,144 @@ pub unsafe fn vrsqrte_f32(a: float32x2_t) -> float32x2_t {
536536
frsqrte_v2f32(a)
537537
}
538538

539+
/// Vector bitwise not.
540+
#[inline]
541+
#[target_feature(enable = "neon")]
542+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
543+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
544+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
545+
pub unsafe fn vmvn_s8(a: int8x8_t) -> int8x8_t {
546+
let b = int8x8_t(-1, -1, -1, -1, -1, -1, -1, -1);
547+
simd_xor(a, b)
548+
}
549+
550+
/// Vector bitwise not.
551+
#[inline]
552+
#[target_feature(enable = "neon")]
553+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
554+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
555+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
556+
pub unsafe fn vmvnq_s8(a: int8x16_t) -> int8x16_t {
557+
let b = int8x16_t(
558+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
559+
);
560+
simd_xor(a, b)
561+
}
562+
563+
/// Vector bitwise not.
564+
#[inline]
565+
#[target_feature(enable = "neon")]
566+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
567+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
568+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
569+
pub unsafe fn vmvn_s16(a: int16x4_t) -> int16x4_t {
570+
let b = int16x4_t(-1, -1, -1, -1);
571+
simd_xor(a, b)
572+
}
573+
574+
/// Vector bitwise not.
575+
#[inline]
576+
#[target_feature(enable = "neon")]
577+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
578+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
579+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
580+
pub unsafe fn vmvnq_s16(a: int16x8_t) -> int16x8_t {
581+
let b = int16x8_t(-1, -1, -1, -1, -1, -1, -1, -1);
582+
simd_xor(a, b)
583+
}
584+
585+
/// Vector bitwise not.
586+
#[inline]
587+
#[target_feature(enable = "neon")]
588+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
589+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
590+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
591+
pub unsafe fn vmvn_s32(a: int32x2_t) -> int32x2_t {
592+
let b = int32x2_t(-1, -1);
593+
simd_xor(a, b)
594+
}
595+
596+
/// Vector bitwise not.
597+
#[inline]
598+
#[target_feature(enable = "neon")]
599+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
600+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
601+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
602+
pub unsafe fn vmvnq_s32(a: int32x4_t) -> int32x4_t {
603+
let b = int32x4_t(-1, -1, -1, -1);
604+
simd_xor(a, b)
605+
}
606+
607+
/// Vector bitwise not.
608+
#[inline]
609+
#[target_feature(enable = "neon")]
610+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
611+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
612+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
613+
pub unsafe fn vmvn_u8(a: uint8x8_t) -> uint8x8_t {
614+
let b = uint8x8_t(255, 255, 255, 255, 255, 255, 255, 255);
615+
simd_xor(a, b)
616+
}
617+
618+
/// Vector bitwise not.
619+
#[inline]
620+
#[target_feature(enable = "neon")]
621+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
622+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
623+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
624+
pub unsafe fn vmvnq_u8(a: uint8x16_t) -> uint8x16_t {
625+
let b = uint8x16_t(
626+
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
627+
);
628+
simd_xor(a, b)
629+
}
630+
631+
/// Vector bitwise not.
632+
#[inline]
633+
#[target_feature(enable = "neon")]
634+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
635+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
636+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
637+
pub unsafe fn vmvn_u16(a: uint16x4_t) -> uint16x4_t {
638+
let b = uint16x4_t(65_535, 65_535, 65_535, 65_535);
639+
simd_xor(a, b)
640+
}
641+
642+
/// Vector bitwise not.
643+
#[inline]
644+
#[target_feature(enable = "neon")]
645+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
646+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
647+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
648+
pub unsafe fn vmvnq_u16(a: uint16x8_t) -> uint16x8_t {
649+
let b = uint16x8_t(
650+
65_535, 65_535, 65_535, 65_535, 65_535, 65_535, 65_535, 65_535,
651+
);
652+
simd_xor(a, b)
653+
}
654+
655+
/// Vector bitwise not.
656+
#[inline]
657+
#[target_feature(enable = "neon")]
658+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
659+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
660+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
661+
pub unsafe fn vmvn_u32(a: uint32x2_t) -> uint32x2_t {
662+
let b = uint32x2_t(4_294_967_295, 4_294_967_295);
663+
simd_xor(a, b)
664+
}
665+
666+
/// Vector bitwise not.
667+
#[inline]
668+
#[target_feature(enable = "neon")]
669+
#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
670+
#[cfg_attr(all(test, target_arch = "arm"), assert_instr(vmvn))]
671+
#[cfg_attr(all(test, target_arch = "aarch64"), assert_instr(mvn))]
672+
pub unsafe fn vmvnq_u32(a: uint32x4_t) -> uint32x4_t {
673+
let b = uint32x4_t(4_294_967_295, 4_294_967_295, 4_294_967_295, 4_294_967_295);
674+
simd_xor(a, b)
675+
}
676+
539677
/// Folding minimum of adjacent pairs
540678
#[inline]
541679
#[target_feature(enable = "neon")]
@@ -1166,6 +1304,108 @@ mod tests {
11661304
assert_eq!(r, e);
11671305
}
11681306

1307+
#[simd_test(enable = "neon")]
1308+
unsafe fn test_vmvn_s8() {
1309+
let a = i8x8::new(0, 1, 2, 3, 4, 5, 6, 7);
1310+
let e = i8x8::new(-1, -2, -3, -4, -5, -6, -7, -8);
1311+
let r: i8x8 = transmute(vmvn_s8(transmute(a)));
1312+
assert_eq!(r, e);
1313+
}
1314+
1315+
#[simd_test(enable = "neon")]
1316+
unsafe fn test_vmvnq_s8() {
1317+
let a = i8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
1318+
let e = i8x16::new(
1319+
-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16,
1320+
);
1321+
let r: i8x16 = transmute(vmvnq_s8(transmute(a)));
1322+
assert_eq!(r, e);
1323+
}
1324+
1325+
#[simd_test(enable = "neon")]
1326+
unsafe fn test_vmvn_s16() {
1327+
let a = i16x4::new(0, 1, 2, 3);
1328+
let e = i16x4::new(-1, -2, -3, -4);
1329+
let r: i16x4 = transmute(vmvn_s16(transmute(a)));
1330+
assert_eq!(r, e);
1331+
}
1332+
1333+
#[simd_test(enable = "neon")]
1334+
unsafe fn test_vmvnq_s16() {
1335+
let a = i16x8::new(0, 1, 2, 3, 4, 5, 6, 7);
1336+
let e = i16x8::new(-1, -2, -3, -4, -5, -6, -7, -8);
1337+
let r: i16x8 = transmute(vmvnq_s16(transmute(a)));
1338+
assert_eq!(r, e);
1339+
}
1340+
1341+
#[simd_test(enable = "neon")]
1342+
unsafe fn test_vmvn_s32() {
1343+
let a = i32x2::new(0, 1);
1344+
let e = i32x2::new(-1, -2);
1345+
let r: i32x2 = transmute(vmvn_s32(transmute(a)));
1346+
assert_eq!(r, e);
1347+
}
1348+
1349+
#[simd_test(enable = "neon")]
1350+
unsafe fn test_vmvnq_s32() {
1351+
let a = i32x4::new(0, 1, 2, 3);
1352+
let e = i32x4::new(-1, -2, -3, -4);
1353+
let r: i32x4 = transmute(vmvnq_s32(transmute(a)));
1354+
assert_eq!(r, e);
1355+
}
1356+
1357+
#[simd_test(enable = "neon")]
1358+
unsafe fn test_vmvn_u8() {
1359+
let a = u8x8::new(0, 1, 2, 3, 4, 5, 6, 7);
1360+
let e = u8x8::new(255, 254, 253, 252, 251, 250, 249, 248);
1361+
let r: u8x8 = transmute(vmvn_u8(transmute(a)));
1362+
assert_eq!(r, e);
1363+
}
1364+
1365+
#[simd_test(enable = "neon")]
1366+
unsafe fn test_vmvnq_u8() {
1367+
let a = u8x16::new(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
1368+
let e = u8x16::new(
1369+
255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240,
1370+
);
1371+
let r: u8x16 = transmute(vmvnq_u8(transmute(a)));
1372+
assert_eq!(r, e);
1373+
}
1374+
1375+
#[simd_test(enable = "neon")]
1376+
unsafe fn test_vmvn_u16() {
1377+
let a = u16x4::new(0, 1, 2, 3);
1378+
let e = u16x4::new(65_535, 65_534, 65_533, 65_532);
1379+
let r: u16x4 = transmute(vmvn_u16(transmute(a)));
1380+
assert_eq!(r, e);
1381+
}
1382+
1383+
#[simd_test(enable = "neon")]
1384+
unsafe fn test_vmvnq_u16() {
1385+
let a = u16x8::new(0, 1, 2, 3, 4, 5, 6, 7);
1386+
let e = u16x8::new(
1387+
65_535, 65_534, 65_533, 65_532, 65_531, 65_530, 65_529, 65_528,
1388+
);
1389+
let r: u16x8 = transmute(vmvnq_u16(transmute(a)));
1390+
assert_eq!(r, e);
1391+
}
1392+
1393+
#[simd_test(enable = "neon")]
1394+
unsafe fn test_vmvn_u32() {
1395+
let a = u32x2::new(0, 1);
1396+
let e = u32x2::new(4_294_967_295, 4_294_967_294);
1397+
let r: u32x2 = transmute(vmvn_u32(transmute(a)));
1398+
assert_eq!(r, e);
1399+
}
1400+
1401+
#[simd_test(enable = "neon")]
1402+
unsafe fn test_vmvnq_u32() {
1403+
let a = u32x4::new(0, 1, 2, 3);
1404+
let e = u32x4::new(4_294_967_295, 4_294_967_294, 4_294_967_293, 4_294_967_292);
1405+
let r: u32x4 = transmute(vmvnq_u32(transmute(a)));
1406+
assert_eq!(r, e);
1407+
}
1408+
11691409
#[simd_test(enable = "neon")]
11701410
unsafe fn test_vmovn_s16() {
11711411
let a = i16x8::new(1, 2, 3, 4, 5, 6, 7, 8);

0 commit comments

Comments
 (0)