diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/simd/intrinsic/generic-arithmetic-pass.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index c507b8d31..f021ee471 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -1,8 +1,6 @@ // run-pass #![allow(non_camel_case_types)] - // ignore-emscripten FIXME(#45351) hits an LLVM assert - #![feature(repr_simd, platform_intrinsics)] #[repr(simd)] @@ -22,7 +20,7 @@ macro_rules! all_eq { let a = $a; let b = $b; assert!(a.0 == b.0 && a.1 == b.1 && a.2 == b.2 && a.3 == b.3); - }} + }}; } macro_rules! all_eq_ { @@ -30,10 +28,9 @@ macro_rules! all_eq_ { let a = $a; let b = $b; assert!(a.0 == b.0); - }} + }}; } - extern "platform-intrinsic" { fn simd_add<T>(x: T, y: T) -> T; fn simd_sub<T>(x: T, y: T) -> T; @@ -47,6 +44,10 @@ extern "platform-intrinsic" { fn simd_xor<T>(x: T, y: T) -> T; fn simd_neg<T>(x: T) -> T; + fn simd_bswap<T>(x: T) -> T; + fn simd_bitreverse<T>(x: T) -> T; + fn simd_ctlz<T>(x: T) -> T; + fn simd_cttz<T>(x: T) -> T; } fn main() { @@ -84,8 +85,8 @@ fn main() { all_eq_!(simd_div(y1, y1), U32::<4>([1, 1, 1, 1])); all_eq_!(simd_div(U32::<4>([2, 4, 6, 8]), U32::<4>([2, 2, 2, 2])), y1); all_eq!(simd_div(z1, z1), f32x4(1.0, 1.0, 1.0, 1.0)); - all_eq!(simd_div(z1, z2), f32x4(1.0/2.0, 2.0/3.0, 3.0/4.0, 4.0/5.0)); - all_eq!(simd_div(z2, z1), f32x4(2.0/1.0, 3.0/2.0, 4.0/3.0, 5.0/4.0)); + all_eq!(simd_div(z1, z2), f32x4(1.0 / 2.0, 2.0 / 3.0, 3.0 / 4.0, 4.0 / 5.0)); + all_eq!(simd_div(z2, z1), f32x4(2.0 / 1.0, 3.0 / 2.0, 4.0 / 3.0, 5.0 / 4.0)); all_eq!(simd_rem(x1, x1), i32x4(0, 0, 0, 0)); all_eq!(simd_rem(x2, x1), i32x4(0, 1, 1, 1)); @@ -109,8 +110,10 @@ fn main() { // ensure we get logical vs. arithmetic shifts correct let (a, b, c, d) = (-12, -123, -1234, -12345); all_eq!(simd_shr(i32x4(a, b, c, d), x1), i32x4(a >> 1, b >> 2, c >> 3, d >> 4)); - all_eq_!(simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), - U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4])); + all_eq_!( + simd_shr(U32::<4>([a as u32, b as u32, c as u32, d as u32]), y1), + U32::<4>([(a as u32) >> 1, (b as u32) >> 2, (c as u32) >> 3, (d as u32) >> 4]) + ); all_eq!(simd_and(x1, x2), i32x4(0, 2, 0, 4)); all_eq!(simd_and(x2, x1), i32x4(0, 2, 0, 4)); @@ -132,5 +135,19 @@ fn main() { all_eq!(simd_neg(z1), f32x4(-1.0, -2.0, -3.0, -4.0)); all_eq!(simd_neg(z2), f32x4(-2.0, -3.0, -4.0, -5.0)); + all_eq!(simd_bswap(x1), i32x4(0x01000000, 0x02000000, 0x03000000, 0x04000000)); + all_eq_!(simd_bswap(y1), U32::<4>([0x01000000, 0x02000000, 0x03000000, 0x04000000])); + + all_eq!( + simd_bitreverse(x1), + i32x4(0x80000000u32 as i32, 0x40000000, 0xc0000000u32 as i32, 0x20000000) + ); + all_eq_!(simd_bitreverse(y1), U32::<4>([0x80000000, 0x40000000, 0xc0000000, 0x20000000])); + + all_eq!(simd_ctlz(x1), i32x4(31, 30, 30, 29)); + all_eq_!(simd_ctlz(y1), U32::<4>([31, 30, 30, 29])); + + all_eq!(simd_cttz(x1), i32x4(0, 1, 0, 2)); + all_eq_!(simd_cttz(y1), U32::<4>([0, 1, 0, 2])); } } |