1 // compile-flags: -C no-prepopulate-passes
6 #![feature(repr_simd, platform_intrinsics)]
7 #![allow(non_camel_case_types)]
10 #[derive(Copy, Clone)]
11 pub struct u32x2(u32, u32);
14 #[derive(Copy, Clone)]
15 pub struct i32x2(i32, i32);
18 #[derive(Copy, Clone)]
20 i8, i8, i8, i8, i8, i8, i8, i8,
21 i8, i8, i8, i8, i8, i8, i8, i8,
25 extern "platform-intrinsic" {
26 fn simd_bitmask<T, U>(x: T) -> U;
29 // NOTE(eddyb) `%{{x|_2}}` is used because on some targets (e.g. WASM)
30 // SIMD vectors are passed directly, resulting in `%x` being a vector,
31 // while on others they're passed indirectly, resulting in `%x` being
32 // a pointer to a vector, and `%_2` a vector loaded from that pointer.
33 // This is controlled by the target spec option `simd_types_indirect`.
35 // CHECK-LABEL: @bitmask_int
37 pub unsafe fn bitmask_int(x: i32x2) -> u8 {
38 // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> %{{x|_2}}, <i32 31, i32 31>
39 // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
40 // CHECK: [[C:%[0-9]+]] = bitcast <2 x i1> [[B]] to i2
41 // CHECK: %{{[0-9]+}} = zext i2 [[C]] to i8
45 // CHECK-LABEL: @bitmask_uint
47 pub unsafe fn bitmask_uint(x: u32x2) -> u8 {
48 // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> %{{x|_2}}, <i32 31, i32 31>
49 // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
50 // CHECK: [[C:%[0-9]+]] = bitcast <2 x i1> [[B]] to i2
51 // CHECK: %{{[0-9]+}} = zext i2 [[C]] to i8
55 // CHECK-LABEL: @bitmask_int16
57 pub unsafe fn bitmask_int16(x: i8x16) -> u16 {
58 // CHECK: [[A:%[0-9]+]] = lshr <16 x i8> %{{x|_2}}, <i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7, i8 7>
59 // CHECK: [[B:%[0-9]+]] = trunc <16 x i8> [[A]] to <16 x i1>
60 // CHECK: %{{[0-9]+}} = bitcast <16 x i1> [[B]] to i16