Skip to content

Commit 0e85e1b

Browse files
committed
Add exclusive or operation
1 parent 1d8469b commit 0e85e1b

File tree

1 file changed

+152
-0
lines changed

1 file changed

+152
-0
lines changed

crates/core_arch/src/arm/neon.rs

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,30 @@ arm_simd_orr!(vorrq_u32, uint32x4_t);
758758
arm_simd_orr!(vorr_u64, uint64x1_t);
759759
arm_simd_orr!(vorrq_u64, uint64x2_t);
760760

761+
macro_rules! arm_simd_eor {
762+
($name:ident, $type:ty) => {
763+
/// Vector bitwise exclusive or (vector).
764+
arm_simd_2!($name, $type, simd_xor, veor, eor);
765+
};
766+
}
767+
768+
arm_simd_eor!(veor_s8, int8x8_t);
769+
arm_simd_eor!(veorq_s8, int8x16_t);
770+
arm_simd_eor!(veor_s16, int16x4_t);
771+
arm_simd_eor!(veorq_s16, int16x8_t);
772+
arm_simd_eor!(veor_s32, int32x2_t);
773+
arm_simd_eor!(veorq_s32, int32x4_t);
774+
arm_simd_eor!(veor_s64, int64x1_t);
775+
arm_simd_eor!(veorq_s64, int64x2_t);
776+
arm_simd_eor!(veor_u8, uint8x8_t);
777+
arm_simd_eor!(veorq_u8, uint8x16_t);
778+
arm_simd_eor!(veor_u16, uint16x4_t);
779+
arm_simd_eor!(veorq_u16, uint16x8_t);
780+
arm_simd_eor!(veor_u32, uint32x2_t);
781+
arm_simd_eor!(veorq_u32, uint32x4_t);
782+
arm_simd_eor!(veor_u64, uint64x1_t);
783+
arm_simd_eor!(veorq_u64, uint64x2_t);
784+
761785
/// Folding minimum of adjacent pairs
762786
#[inline]
763787
#[target_feature(enable = "neon")]
@@ -1764,6 +1788,134 @@ mod tests {
17641788
assert_eq!(r, a);
17651789
}
17661790

1791+
#[simd_test(enable = "neon")]
1792+
unsafe fn test_veor_s8() {
1793+
let a = i8x8::new(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
1794+
let b = i8x8::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
1795+
let r: i8x8 = transmute(veor_s8(transmute(a), transmute(a)));
1796+
assert_eq!(r, b);
1797+
}
1798+
1799+
#[simd_test(enable = "neon")]
1800+
unsafe fn test_veorq_s8() {
1801+
let a = i8x16::new(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F);
1802+
let b = i8x16::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
1803+
let r: i8x16 = transmute(veorq_s8(transmute(a), transmute(a)));
1804+
assert_eq!(r, b);
1805+
}
1806+
1807+
#[simd_test(enable = "neon")]
1808+
unsafe fn test_veor_s16() {
1809+
let a = i16x4::new(0x0001, 0x0203, 0x0405, 0x0607);
1810+
let b = i16x4::new(0x0000, 0x0000, 0x0000, 0x0000);
1811+
let r: i16x4 = transmute(veor_s16(transmute(a), transmute(a)));
1812+
assert_eq!(r, b);
1813+
}
1814+
1815+
#[simd_test(enable = "neon")]
1816+
unsafe fn test_veorq_s16() {
1817+
let a = i16x8::new(0x0001, 0x0203, 0x0405, 0x0607, 0x0809, 0x0A0B, 0x0C0D, 0x0E0F);
1818+
let b = i16x8::new(0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000);
1819+
let r: i16x8 = transmute(veorq_s16(transmute(a), transmute(a)));
1820+
assert_eq!(r, b);
1821+
}
1822+
1823+
#[simd_test(enable = "neon")]
1824+
unsafe fn test_veor_s32() {
1825+
let a = i32x2::new(0x00010203, 0x04050607);
1826+
let b = i32x2::new(0x00000000, 0x00000000);
1827+
let r: i32x2 = transmute(veor_s32(transmute(a), transmute(a)));
1828+
assert_eq!(r, b);
1829+
}
1830+
1831+
#[simd_test(enable = "neon")]
1832+
unsafe fn test_veorq_s32() {
1833+
let a = i32x4::new(0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F);
1834+
let b = i32x4::new(0x00000000, 0x00000000, 0x00000000, 0x00000000);
1835+
let r: i32x4 = transmute(veorq_s32(transmute(a), transmute(a)));
1836+
assert_eq!(r, b);
1837+
}
1838+
1839+
#[simd_test(enable = "neon")]
1840+
unsafe fn test_veor_s64() {
1841+
let a = i64x1::new(0x0001020304050607);
1842+
let b = i64x1::new(0x0000000000000000);
1843+
let r: i64x1 = transmute(veor_s64(transmute(a), transmute(a)));
1844+
assert_eq!(r, b);
1845+
}
1846+
1847+
#[simd_test(enable = "neon")]
1848+
unsafe fn test_veorq_s64() {
1849+
let a = i64x2::new(0x0001020304050607, 0x08090A0B0C0D0E0F);
1850+
let b = i64x2::new(0x0000000000000000, 0x0000000000000000);
1851+
let r: i64x2 = transmute(veorq_s64(transmute(a), transmute(a)));
1852+
assert_eq!(r, b);
1853+
}
1854+
1855+
#[simd_test(enable = "neon")]
1856+
unsafe fn test_veor_u8() {
1857+
let a = u8x8::new(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07);
1858+
let b = u8x8::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
1859+
let r: u8x8 = transmute(veor_u8(transmute(a), transmute(a)));
1860+
assert_eq!(r, b);
1861+
}
1862+
1863+
#[simd_test(enable = "neon")]
1864+
unsafe fn test_veorq_u8() {
1865+
let a = u8x16::new(0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F);
1866+
let b = u8x16::new(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
1867+
let r: u8x16 = transmute(veorq_u8(transmute(a), transmute(a)));
1868+
assert_eq!(r, b);
1869+
}
1870+
1871+
#[simd_test(enable = "neon")]
1872+
unsafe fn test_veor_u16() {
1873+
let a = u16x4::new(0x0001, 0x0203, 0x0405, 0x0607);
1874+
let b = u16x4::new(0x0000, 0x0000, 0x0000, 0x0000);
1875+
let r: u16x4 = transmute(veor_u16(transmute(a), transmute(a)));
1876+
assert_eq!(r, b);
1877+
}
1878+
1879+
#[simd_test(enable = "neon")]
1880+
unsafe fn test_veorq_u16() {
1881+
let a = u16x8::new(0x0001, 0x0203, 0x0405, 0x0607, 0x0809, 0x0A0B, 0x0C0D, 0x0E0F);
1882+
let b = u16x8::new(0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000);
1883+
let r: u16x8 = transmute(veorq_u16(transmute(a), transmute(a)));
1884+
assert_eq!(r, b);
1885+
}
1886+
1887+
#[simd_test(enable = "neon")]
1888+
unsafe fn test_veor_u32() {
1889+
let a = u32x2::new(0x00010203, 0x04050607);
1890+
let b = u32x2::new(0x00000000, 0x00000000);
1891+
let r: u32x2 = transmute(veor_u32(transmute(a), transmute(a)));
1892+
assert_eq!(r, b);
1893+
}
1894+
1895+
#[simd_test(enable = "neon")]
1896+
unsafe fn test_veorq_u32() {
1897+
let a = u32x4::new(0x00010203, 0x04050607, 0x08090A0B, 0x0C0D0E0F);
1898+
let b = u32x4::new(0x00000000, 0x00000000, 0x00000000, 0x00000000);
1899+
let r: u32x4 = transmute(veorq_u32(transmute(a), transmute(a)));
1900+
assert_eq!(r, b);
1901+
}
1902+
1903+
#[simd_test(enable = "neon")]
1904+
unsafe fn test_veor_u64() {
1905+
let a = u64x1::new(0x0001020304050607);
1906+
let b = u64x1::new(0x0000000000000000);
1907+
let r: u64x1 = transmute(veor_u64(transmute(a), transmute(a)));
1908+
assert_eq!(r, b);
1909+
}
1910+
1911+
#[simd_test(enable = "neon")]
1912+
unsafe fn test_veorq_u64() {
1913+
let a = u64x2::new(0x0001020304050607, 0x08090A0B0C0D0E0F);
1914+
let b = u64x2::new(0x0000000000000000, 0x0000000000000000);
1915+
let r: u64x2 = transmute(veorq_u64(transmute(a), transmute(a)));
1916+
assert_eq!(r, b);
1917+
}
1918+
17671919
#[simd_test(enable = "neon")]
17681920
unsafe fn test_vmovn_s16() {
17691921
let a = i16x8::new(1, 2, 3, 4, 5, 6, 7, 8);

0 commit comments

Comments
 (0)