2 #![allow(non_camel_case_types)]
5 // ignore-mips behavior of simd_select_bitmask is endian-specific
6 // ignore-mips64 behavior of simd_select_bitmask is endian-specific
7 // ignore-powerpc behavior of simd_select_bitmask is endian-specific
8 // ignore-powerpc64 behavior of simd_select_bitmask is endian-specific
10 // Test that the simd_select intrinsics produces correct results.
12 #![feature(repr_simd, platform_intrinsics)]
13 #[allow(non_camel_case_types)]
16 #[derive(Copy, Clone, PartialEq, Debug)]
17 struct i32x4(pub i32, pub i32, pub i32, pub i32);
20 #[derive(Copy, Clone, PartialEq, Debug)]
21 struct u32x4(pub u32, pub u32, pub u32, pub u32);
24 #[derive(Copy, Clone, PartialEq, Debug)]
25 struct u32x8(u32, u32, u32, u32, u32, u32, u32, u32);
28 #[derive(Copy, Clone, PartialEq, Debug)]
29 struct f32x4(pub f32, pub f32, pub f32, pub f32);
32 #[derive(Copy, Clone, PartialEq, Debug)]
33 struct b8x4(pub i8, pub i8, pub i8, pub i8);
35 extern "platform-intrinsic" {
36 fn simd_select<T, U>(x: T, a: U, b: U) -> U;
37 fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U;
41 let m0 = b8x4(!0, !0, !0, !0);
42 let m1 = b8x4(0, 0, 0, 0);
43 let m2 = b8x4(!0, !0, 0, 0);
44 let m3 = b8x4(0, 0, !0, !0);
45 let m4 = b8x4(!0, 0, !0, 0);
48 let a = i32x4(1, -2, 3, 4);
49 let b = i32x4(5, 6, -7, 8);
51 let r: i32x4 = simd_select(m0, a, b);
55 let r: i32x4 = simd_select(m1, a, b);
59 let r: i32x4 = simd_select(m2, a, b);
60 let e = i32x4(1, -2, -7, 8);
63 let r: i32x4 = simd_select(m3, a, b);
64 let e = i32x4(5, 6, 3, 4);
67 let r: i32x4 = simd_select(m4, a, b);
68 let e = i32x4(1, 6, 3, 8);
73 let a = u32x4(1, 2, 3, 4);
74 let b = u32x4(5, 6, 7, 8);
76 let r: u32x4 = simd_select(m0, a, b);
80 let r: u32x4 = simd_select(m1, a, b);
84 let r: u32x4 = simd_select(m2, a, b);
85 let e = u32x4(1, 2, 7, 8);
88 let r: u32x4 = simd_select(m3, a, b);
89 let e = u32x4(5, 6, 3, 4);
92 let r: u32x4 = simd_select(m4, a, b);
93 let e = u32x4(1, 6, 3, 8);
98 let a = f32x4(1., 2., 3., 4.);
99 let b = f32x4(5., 6., 7., 8.);
101 let r: f32x4 = simd_select(m0, a, b);
105 let r: f32x4 = simd_select(m1, a, b);
109 let r: f32x4 = simd_select(m2, a, b);
110 let e = f32x4(1., 2., 7., 8.);
113 let r: f32x4 = simd_select(m3, a, b);
114 let e = f32x4(5., 6., 3., 4.);
117 let r: f32x4 = simd_select(m4, a, b);
118 let e = f32x4(1., 6., 3., 8.);
125 let a = b8x4(t, f, t, f);
126 let b = b8x4(f, f, f, t);
128 let r: b8x4 = simd_select(m0, a, b);
132 let r: b8x4 = simd_select(m1, a, b);
136 let r: b8x4 = simd_select(m2, a, b);
137 let e = b8x4(t, f, f, t);
140 let r: b8x4 = simd_select(m3, a, b);
141 let e = b8x4(f, f, t, f);
144 let r: b8x4 = simd_select(m4, a, b);
145 let e = b8x4(t, f, t, t);
150 let a = u32x8(0, 1, 2, 3, 4, 5, 6, 7);
151 let b = u32x8(8, 9, 10, 11, 12, 13, 14, 15);
153 let r: u32x8 = simd_select_bitmask(0u8, a, b);
157 let r: u32x8 = simd_select_bitmask(0xffu8, a, b);
161 let r: u32x8 = simd_select_bitmask(0b01010101u8, a, b);
162 let e = u32x8(0, 9, 2, 11, 4, 13, 6, 15);
165 let r: u32x8 = simd_select_bitmask(0b10101010u8, a, b);
166 let e = u32x8(8, 1, 10, 3, 12, 5, 14, 7);
169 let r: u32x8 = simd_select_bitmask(0b11110000u8, a, b);
170 let e = u32x8(8, 9, 10, 11, 4, 5, 6, 7);