2 #![allow(non_camel_case_types)]
5 // ignore-endian-big behavior of simd_select_bitmask is endian-specific
7 // Test that the simd_select intrinsics produces correct results.
9 #![feature(repr_simd, platform_intrinsics)]
10 #[allow(non_camel_case_types)]
13 #[derive(Copy, Clone, PartialEq, Debug)]
14 struct i32x4(pub i32, pub i32, pub i32, pub i32);
17 #[derive(Copy, Clone, PartialEq, Debug)]
18 struct u32x4(pub u32, pub u32, pub u32, pub u32);
21 #[derive(Copy, Clone, PartialEq, Debug)]
22 struct u32x8(u32, u32, u32, u32, u32, u32, u32, u32);
25 #[derive(Copy, Clone, PartialEq, Debug)]
26 struct f32x4(pub f32, pub f32, pub f32, pub f32);
29 #[derive(Copy, Clone, PartialEq, Debug)]
30 struct b8x4(pub i8, pub i8, pub i8, pub i8);
32 extern "platform-intrinsic" {
33 fn simd_select<T, U>(x: T, a: U, b: U) -> U;
34 fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
38 let m0 = b8x4(!0, !0, !0, !0);
39 let m1 = b8x4(0, 0, 0, 0);
40 let m2 = b8x4(!0, !0, 0, 0);
41 let m3 = b8x4(0, 0, !0, !0);
42 let m4 = b8x4(!0, 0, !0, 0);
45 let a = i32x4(1, -2, 3, 4);
46 let b = i32x4(5, 6, -7, 8);
48 let r: i32x4 = simd_select(m0, a, b);
52 let r: i32x4 = simd_select(m1, a, b);
56 let r: i32x4 = simd_select(m2, a, b);
57 let e = i32x4(1, -2, -7, 8);
60 let r: i32x4 = simd_select(m3, a, b);
61 let e = i32x4(5, 6, 3, 4);
64 let r: i32x4 = simd_select(m4, a, b);
65 let e = i32x4(1, 6, 3, 8);
70 let a = u32x4(1, 2, 3, 4);
71 let b = u32x4(5, 6, 7, 8);
73 let r: u32x4 = simd_select(m0, a, b);
77 let r: u32x4 = simd_select(m1, a, b);
81 let r: u32x4 = simd_select(m2, a, b);
82 let e = u32x4(1, 2, 7, 8);
85 let r: u32x4 = simd_select(m3, a, b);
86 let e = u32x4(5, 6, 3, 4);
89 let r: u32x4 = simd_select(m4, a, b);
90 let e = u32x4(1, 6, 3, 8);
95 let a = f32x4(1., 2., 3., 4.);
96 let b = f32x4(5., 6., 7., 8.);
98 let r: f32x4 = simd_select(m0, a, b);
102 let r: f32x4 = simd_select(m1, a, b);
106 let r: f32x4 = simd_select(m2, a, b);
107 let e = f32x4(1., 2., 7., 8.);
110 let r: f32x4 = simd_select(m3, a, b);
111 let e = f32x4(5., 6., 3., 4.);
114 let r: f32x4 = simd_select(m4, a, b);
115 let e = f32x4(1., 6., 3., 8.);
122 let a = b8x4(t, f, t, f);
123 let b = b8x4(f, f, f, t);
125 let r: b8x4 = simd_select(m0, a, b);
129 let r: b8x4 = simd_select(m1, a, b);
133 let r: b8x4 = simd_select(m2, a, b);
134 let e = b8x4(t, f, f, t);
137 let r: b8x4 = simd_select(m3, a, b);
138 let e = b8x4(f, f, t, f);
141 let r: b8x4 = simd_select(m4, a, b);
142 let e = b8x4(t, f, t, t);
147 let a = u32x8(0, 1, 2, 3, 4, 5, 6, 7);
148 let b = u32x8(8, 9, 10, 11, 12, 13, 14, 15);
150 let r: u32x8 = simd_select_bitmask(0u8, a, b);
154 let r: u32x8 = simd_select_bitmask(0xffu8, a, b);
158 let r: u32x8 = simd_select_bitmask(0b01010101u8, a, b);
159 let e = u32x8(0, 9, 2, 11, 4, 13, 6, 15);
162 let r: u32x8 = simd_select_bitmask(0b10101010u8, a, b);
163 let e = u32x8(8, 1, 10, 3, 12, 5, 14, 7);
166 let r: u32x8 = simd_select_bitmask(0b11110000u8, a, b);
167 let e = u32x8(8, 9, 10, 11, 4, 5, 6, 7);