]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/simd-intrinsic/simd-intrinsic-generic-bitmask.rs
Auto merge of #55780 - ogoffart:span_source_text, r=petrochenkov
[rust.git] / src / test / codegen / simd-intrinsic / simd-intrinsic-generic-bitmask.rs
1 // compile-flags: -C no-prepopulate-passes
2 // ignore-tidy-linelength
3
4 #![crate_type = "lib"]
5
6 #![feature(repr_simd, platform_intrinsics)]
7 #![allow(non_camel_case_types)]
8
9 #[repr(simd)]
10 #[derive(Copy, Clone)]
11 pub struct u32x2(u32, u32);
12
13 #[repr(simd)]
14 #[derive(Copy, Clone)]
15 pub struct i32x2(i32, i32);
16
17 #[repr(simd)]
18 #[derive(Copy, Clone)]
19 pub struct i8x16(
20     i8, i8, i8, i8, i8, i8, i8, i8,
21     i8, i8, i8, i8, i8, i8, i8, i8,
22 );
23
24
25 extern "platform-intrinsic" {
26     fn simd_bitmask<T, U>(x: T) -> U;
27 }
28
29 // CHECK-LABEL: @bitmask_int
30 #[no_mangle]
31 pub unsafe fn bitmask_int(x: i32x2) -> u8 {
32     // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> %{{[0-9]+}}, <i32 31, i32 31>
33     // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
34     // CHECK: [[C:%[0-9]+]] = bitcast <2 x i1> [[B]] to i2
35     // CHECK: %{{[0-9]+}} = zext i2 [[C]] to i8
36     simd_bitmask(x)
37 }
38
39 // CHECK-LABEL: @bitmask_uint
40 #[no_mangle]
41 pub unsafe fn bitmask_uint(x: u32x2) -> u8 {
42     // CHECK: [[A:%[0-9]+]] = lshr <2 x i32> %{{[0-9]+}}, <i32 31, i32 31>
43     // CHECK: [[B:%[0-9]+]] = trunc <2 x i32> [[A]] to <2 x i1>
44     // CHECK: [[C:%[0-9]+]] = bitcast <2 x i1> [[B]] to i2
45     // CHECK: %{{[0-9]+}} = zext i2 [[C]] to i8
46     simd_bitmask(x)
47 }
48
49 // CHECK-LABEL: @bitmask_int16
50 #[no_mangle]
51 pub unsafe fn bitmask_int16(x: i8x16) -> u16 {
52     // CHECK: [[A:%[0-9]+]] = lshr <16 x i8> %{{[0-9]+}}, <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>
53     // CHECK: [[B:%[0-9]+]] = trunc <16 x i8> [[A]] to <16 x i1>
54     // CHECK: %{{[0-9]+}} = bitcast <16 x i1> [[B]] to i16
55     // CHECK-NOT: zext
56     simd_bitmask(x)
57 }