]> git.lizzy.rs Git - rust.git/blob - tests/codegen/simd-intrinsic/simd-intrinsic-generic-arithmetic-saturating.rs
Rollup merge of #106244 - atouchet:readme3, r=workingjubilee
[rust.git] / tests / codegen / simd-intrinsic / simd-intrinsic-generic-arithmetic-saturating.rs
1 // compile-flags: -C no-prepopulate-passes
2 //
3
4 #![crate_type = "lib"]
5
6 #![feature(repr_simd, platform_intrinsics)]
7 #![allow(non_camel_case_types)]
8 #![deny(unused)]
9
10 // signed integer types
11
12 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x2(i8, i8);
13 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x4(i8, i8, i8, i8);
14 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x8(
15     i8, i8, i8, i8, i8, i8, i8, i8,
16 );
17 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x16(
18     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
19 );
20 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x32(
21     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
22     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
23 );
24 #[repr(simd)] #[derive(Copy, Clone)] pub struct i8x64(
25     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
26     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
27     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
28     i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8,
29 );
30
31 #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x2(i16, i16);
32 #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x4(i16, i16, i16, i16);
33 #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x8(
34     i16, i16, i16, i16, i16, i16, i16, i16,
35 );
36 #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x16(
37     i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16,
38 );
39 #[repr(simd)] #[derive(Copy, Clone)] pub struct i16x32(
40     i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16,
41     i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16, i16,
42 );
43
44 #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x2(i32, i32);
45 #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x4(i32, i32, i32, i32);
46 #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x8(
47     i32, i32, i32, i32, i32, i32, i32, i32,
48 );
49 #[repr(simd)] #[derive(Copy, Clone)] pub struct i32x16(
50     i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32,
51 );
52
53 #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x2(i64, i64);
54 #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x4(i64, i64, i64, i64);
55 #[repr(simd)] #[derive(Copy, Clone)] pub struct i64x8(
56     i64, i64, i64, i64, i64, i64, i64, i64,
57 );
58
59 #[repr(simd)] #[derive(Copy, Clone)] pub struct i128x2(i128, i128);
60 #[repr(simd)] #[derive(Copy, Clone)] pub struct i128x4(i128, i128, i128, i128);
61
62 // unsigned integer types
63
64 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x2(u8, u8);
65 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x4(u8, u8, u8, u8);
66 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x8(
67     u8, u8, u8, u8, u8, u8, u8, u8,
68 );
69 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x16(
70     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
71 );
72 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x32(
73     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
74     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
75 );
76 #[repr(simd)] #[derive(Copy, Clone)] pub struct u8x64(
77     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
78     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
79     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
80     u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8,
81 );
82
83 #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x2(u16, u16);
84 #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x4(u16, u16, u16, u16);
85 #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x8(
86     u16, u16, u16, u16, u16, u16, u16, u16,
87 );
88 #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x16(
89     u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16,
90 );
91 #[repr(simd)] #[derive(Copy, Clone)] pub struct u16x32(
92     u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16,
93     u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16, u16,
94 );
95
96 #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x2(u32, u32);
97 #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x4(u32, u32, u32, u32);
98 #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x8(
99     u32, u32, u32, u32, u32, u32, u32, u32,
100 );
101 #[repr(simd)] #[derive(Copy, Clone)] pub struct u32x16(
102     u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32, u32,
103 );
104
105 #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x2(u64, u64);
106 #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x4(u64, u64, u64, u64);
107 #[repr(simd)] #[derive(Copy, Clone)] pub struct u64x8(
108     u64, u64, u64, u64, u64, u64, u64, u64,
109 );
110
111 #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x2(u128, u128);
112 #[repr(simd)] #[derive(Copy, Clone)] pub struct u128x4(u128, u128, u128, u128);
113
114 extern "platform-intrinsic" {
115     fn simd_saturating_add<T>(x: T, y: T) -> T;
116     fn simd_saturating_sub<T>(x: T, y: T) -> T;
117 }
118
119 // NOTE(eddyb) `%{{x|_3}}` is used because on some targets (e.g. WASM)
120 // SIMD vectors are passed directly, resulting in `%x` being a vector,
121 // while on others they're passed indirectly, resulting in `%x` being
122 // a pointer to a vector, and `%_3` a vector loaded from that pointer.
123 // This is controlled by the target spec option `simd_types_indirect`.
124 // The same applies to `%{{y|_4}}` as well.
125
126 // CHECK-LABEL: @sadd_i8x2
127 #[no_mangle]
128 pub unsafe fn sadd_i8x2(x: i8x2, y: i8x2) -> i8x2 {
129     // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %{{x|_3}}, <2 x i8> %{{y|_4}})
130     simd_saturating_add(x, y)
131 }
132
133 // CHECK-LABEL: @sadd_i8x4
134 #[no_mangle]
135 pub unsafe fn sadd_i8x4(x: i8x4, y: i8x4) -> i8x4 {
136     // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.sadd.sat.v4i8(<4 x i8> %{{x|_3}}, <4 x i8> %{{y|_4}})
137     simd_saturating_add(x, y)
138 }
139
140 // CHECK-LABEL: @sadd_i8x8
141 #[no_mangle]
142 pub unsafe fn sadd_i8x8(x: i8x8, y: i8x8) -> i8x8 {
143     // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.sadd.sat.v8i8(<8 x i8> %{{x|_3}}, <8 x i8> %{{y|_4}})
144     simd_saturating_add(x, y)
145 }
146
147 // CHECK-LABEL: @sadd_i8x16
148 #[no_mangle]
149 pub unsafe fn sadd_i8x16(x: i8x16, y: i8x16) -> i8x16 {
150     // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.sadd.sat.v16i8(<16 x i8> %{{x|_3}}, <16 x i8> %{{y|_4}})
151     simd_saturating_add(x, y)
152 }
153
154 // CHECK-LABEL: @sadd_i8x32
155 #[no_mangle]
156 pub unsafe fn sadd_i8x32(x: i8x32, y: i8x32) -> i8x32 {
157     // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{x|_3}}, <32 x i8> %{{y|_4}})
158     simd_saturating_add(x, y)
159 }
160
161 // CHECK-LABEL: @sadd_i8x64
162 #[no_mangle]
163 pub unsafe fn sadd_i8x64(x: i8x64, y: i8x64) -> i8x64 {
164     // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.sadd.sat.v64i8(<64 x i8> %{{x|_3}}, <64 x i8> %{{y|_4}})
165     simd_saturating_add(x, y)
166 }
167
168 // CHECK-LABEL: @sadd_i16x2
169 #[no_mangle]
170 pub unsafe fn sadd_i16x2(x: i16x2, y: i16x2) -> i16x2 {
171     // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.sadd.sat.v2i16(<2 x i16> %{{x|_3}}, <2 x i16> %{{y|_4}})
172     simd_saturating_add(x, y)
173 }
174
175 // CHECK-LABEL: @sadd_i16x4
176 #[no_mangle]
177 pub unsafe fn sadd_i16x4(x: i16x4, y: i16x4) -> i16x4 {
178     // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> %{{x|_3}}, <4 x i16> %{{y|_4}})
179     simd_saturating_add(x, y)
180 }
181
182 // CHECK-LABEL: @sadd_i16x8
183 #[no_mangle]
184 pub unsafe fn sadd_i16x8(x: i16x8, y: i16x8) -> i16x8 {
185     // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.sadd.sat.v8i16(<8 x i16> %{{x|_3}}, <8 x i16> %{{y|_4}})
186     simd_saturating_add(x, y)
187 }
188
189 // CHECK-LABEL: @sadd_i16x16
190 #[no_mangle]
191 pub unsafe fn sadd_i16x16(x: i16x16, y: i16x16) -> i16x16 {
192     // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.sadd.sat.v16i16(<16 x i16> %{{x|_3}}, <16 x i16> %{{y|_4}})
193     simd_saturating_add(x, y)
194 }
195
196 // CHECK-LABEL: @sadd_i16x32
197 #[no_mangle]
198 pub unsafe fn sadd_i16x32(x: i16x32, y: i16x32) -> i16x32 {
199     // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.sadd.sat.v32i16(<32 x i16> %{{x|_3}}, <32 x i16> %{{y|_4}})
200     simd_saturating_add(x, y)
201 }
202
203 // CHECK-LABEL: @sadd_i32x2
204 #[no_mangle]
205 pub unsafe fn sadd_i32x2(x: i32x2, y: i32x2) -> i32x2 {
206     // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> %{{x|_3}}, <2 x i32> %{{y|_4}})
207     simd_saturating_add(x, y)
208 }
209
210 // CHECK-LABEL: @sadd_i32x4
211 #[no_mangle]
212 pub unsafe fn sadd_i32x4(x: i32x4, y: i32x4) -> i32x4 {
213     // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %{{x|_3}}, <4 x i32> %{{y|_4}})
214     simd_saturating_add(x, y)
215 }
216
217 // CHECK-LABEL: @sadd_i32x8
218 #[no_mangle]
219 pub unsafe fn sadd_i32x8(x: i32x8, y: i32x8) -> i32x8 {
220     // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.sadd.sat.v8i32(<8 x i32> %{{x|_3}}, <8 x i32> %{{y|_4}})
221     simd_saturating_add(x, y)
222 }
223
224 // CHECK-LABEL: @sadd_i32x16
225 #[no_mangle]
226 pub unsafe fn sadd_i32x16(x: i32x16, y: i32x16) -> i32x16 {
227     // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.sadd.sat.v16i32(<16 x i32> %{{x|_3}}, <16 x i32> %{{y|_4}})
228     simd_saturating_add(x, y)
229 }
230
231 // CHECK-LABEL: @sadd_i64x2
232 #[no_mangle]
233 pub unsafe fn sadd_i64x2(x: i64x2, y: i64x2) -> i64x2 {
234     // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %{{x|_3}}, <2 x i64> %{{y|_4}})
235     simd_saturating_add(x, y)
236 }
237
238 // CHECK-LABEL: @sadd_i64x4
239 #[no_mangle]
240 pub unsafe fn sadd_i64x4(x: i64x4, y: i64x4) -> i64x4 {
241     // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.sadd.sat.v4i64(<4 x i64> %{{x|_3}}, <4 x i64> %{{y|_4}})
242     simd_saturating_add(x, y)
243 }
244
245 // CHECK-LABEL: @sadd_i64x8
246 #[no_mangle]
247 pub unsafe fn sadd_i64x8(x: i64x8, y: i64x8) -> i64x8 {
248     // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.sadd.sat.v8i64(<8 x i64> %{{x|_3}}, <8 x i64> %{{y|_4}})
249     simd_saturating_add(x, y)
250 }
251
252 // CHECK-LABEL: @sadd_i128x2
253 #[no_mangle]
254 pub unsafe fn sadd_i128x2(x: i128x2, y: i128x2) -> i128x2 {
255     // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.sadd.sat.v2i128(<2 x i128> %{{x|_3}}, <2 x i128> %{{y|_4}})
256     simd_saturating_add(x, y)
257 }
258
259 // CHECK-LABEL: @sadd_i128x4
260 #[no_mangle]
261 pub unsafe fn sadd_i128x4(x: i128x4, y: i128x4) -> i128x4 {
262     // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.sadd.sat.v4i128(<4 x i128> %{{x|_3}}, <4 x i128> %{{y|_4}})
263     simd_saturating_add(x, y)
264 }
265
266
267
268 // CHECK-LABEL: @uadd_u8x2
269 #[no_mangle]
270 pub unsafe fn uadd_u8x2(x: u8x2, y: u8x2) -> u8x2 {
271     // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %{{x|_3}}, <2 x i8> %{{y|_4}})
272     simd_saturating_add(x, y)
273 }
274
275 // CHECK-LABEL: @uadd_u8x4
276 #[no_mangle]
277 pub unsafe fn uadd_u8x4(x: u8x4, y: u8x4) -> u8x4 {
278     // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.uadd.sat.v4i8(<4 x i8> %{{x|_3}}, <4 x i8> %{{y|_4}})
279     simd_saturating_add(x, y)
280 }
281
282 // CHECK-LABEL: @uadd_u8x8
283 #[no_mangle]
284 pub unsafe fn uadd_u8x8(x: u8x8, y: u8x8) -> u8x8 {
285     // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.uadd.sat.v8i8(<8 x i8> %{{x|_3}}, <8 x i8> %{{y|_4}})
286     simd_saturating_add(x, y)
287 }
288
289 // CHECK-LABEL: @uadd_u8x16
290 #[no_mangle]
291 pub unsafe fn uadd_u8x16(x: u8x16, y: u8x16) -> u8x16 {
292     // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.uadd.sat.v16i8(<16 x i8> %{{x|_3}}, <16 x i8> %{{y|_4}})
293     simd_saturating_add(x, y)
294 }
295
296 // CHECK-LABEL: @uadd_u8x32
297 #[no_mangle]
298 pub unsafe fn uadd_u8x32(x: u8x32, y: u8x32) -> u8x32 {
299     // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.uadd.sat.v32i8(<32 x i8> %{{x|_3}}, <32 x i8> %{{y|_4}})
300     simd_saturating_add(x, y)
301 }
302
303 // CHECK-LABEL: @uadd_u8x64
304 #[no_mangle]
305 pub unsafe fn uadd_u8x64(x: u8x64, y: u8x64) -> u8x64 {
306     // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.uadd.sat.v64i8(<64 x i8> %{{x|_3}}, <64 x i8> %{{y|_4}})
307     simd_saturating_add(x, y)
308 }
309
310 // CHECK-LABEL: @uadd_u16x2
311 #[no_mangle]
312 pub unsafe fn uadd_u16x2(x: u16x2, y: u16x2) -> u16x2 {
313     // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.uadd.sat.v2i16(<2 x i16> %{{x|_3}}, <2 x i16> %{{y|_4}})
314     simd_saturating_add(x, y)
315 }
316
317 // CHECK-LABEL: @uadd_u16x4
318 #[no_mangle]
319 pub unsafe fn uadd_u16x4(x: u16x4, y: u16x4) -> u16x4 {
320     // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.uadd.sat.v4i16(<4 x i16> %{{x|_3}}, <4 x i16> %{{y|_4}})
321     simd_saturating_add(x, y)
322 }
323
324 // CHECK-LABEL: @uadd_u16x8
325 #[no_mangle]
326 pub unsafe fn uadd_u16x8(x: u16x8, y: u16x8) -> u16x8 {
327     // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.uadd.sat.v8i16(<8 x i16> %{{x|_3}}, <8 x i16> %{{y|_4}})
328     simd_saturating_add(x, y)
329 }
330
331 // CHECK-LABEL: @uadd_u16x16
332 #[no_mangle]
333 pub unsafe fn uadd_u16x16(x: u16x16, y: u16x16) -> u16x16 {
334     // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.uadd.sat.v16i16(<16 x i16> %{{x|_3}}, <16 x i16> %{{y|_4}})
335     simd_saturating_add(x, y)
336 }
337
338 // CHECK-LABEL: @uadd_u16x32
339 #[no_mangle]
340 pub unsafe fn uadd_u16x32(x: u16x32, y: u16x32) -> u16x32 {
341     // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.uadd.sat.v32i16(<32 x i16> %{{x|_3}}, <32 x i16> %{{y|_4}})
342     simd_saturating_add(x, y)
343 }
344
345 // CHECK-LABEL: @uadd_u32x2
346 #[no_mangle]
347 pub unsafe fn uadd_u32x2(x: u32x2, y: u32x2) -> u32x2 {
348     // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.uadd.sat.v2i32(<2 x i32> %{{x|_3}}, <2 x i32> %{{y|_4}})
349     simd_saturating_add(x, y)
350 }
351
352 // CHECK-LABEL: @uadd_u32x4
353 #[no_mangle]
354 pub unsafe fn uadd_u32x4(x: u32x4, y: u32x4) -> u32x4 {
355     // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.uadd.sat.v4i32(<4 x i32> %{{x|_3}}, <4 x i32> %{{y|_4}})
356     simd_saturating_add(x, y)
357 }
358
359 // CHECK-LABEL: @uadd_u32x8
360 #[no_mangle]
361 pub unsafe fn uadd_u32x8(x: u32x8, y: u32x8) -> u32x8 {
362     // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.uadd.sat.v8i32(<8 x i32> %{{x|_3}}, <8 x i32> %{{y|_4}})
363     simd_saturating_add(x, y)
364 }
365
366 // CHECK-LABEL: @uadd_u32x16
367 #[no_mangle]
368 pub unsafe fn uadd_u32x16(x: u32x16, y: u32x16) -> u32x16 {
369     // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.uadd.sat.v16i32(<16 x i32> %{{x|_3}}, <16 x i32> %{{y|_4}})
370     simd_saturating_add(x, y)
371 }
372
373 // CHECK-LABEL: @uadd_u64x2
374 #[no_mangle]
375 pub unsafe fn uadd_u64x2(x: u64x2, y: u64x2) -> u64x2 {
376     // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.uadd.sat.v2i64(<2 x i64> %{{x|_3}}, <2 x i64> %{{y|_4}})
377     simd_saturating_add(x, y)
378 }
379
380 // CHECK-LABEL: @uadd_u64x4
381 #[no_mangle]
382 pub unsafe fn uadd_u64x4(x: u64x4, y: u64x4) -> u64x4 {
383     // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.uadd.sat.v4i64(<4 x i64> %{{x|_3}}, <4 x i64> %{{y|_4}})
384     simd_saturating_add(x, y)
385 }
386
387 // CHECK-LABEL: @uadd_u64x8
388 #[no_mangle]
389 pub unsafe fn uadd_u64x8(x: u64x8, y: u64x8) -> u64x8 {
390     // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.uadd.sat.v8i64(<8 x i64> %{{x|_3}}, <8 x i64> %{{y|_4}})
391     simd_saturating_add(x, y)
392 }
393
394 // CHECK-LABEL: @uadd_u128x2
395 #[no_mangle]
396 pub unsafe fn uadd_u128x2(x: u128x2, y: u128x2) -> u128x2 {
397     // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.uadd.sat.v2i128(<2 x i128> %{{x|_3}}, <2 x i128> %{{y|_4}})
398     simd_saturating_add(x, y)
399 }
400
401 // CHECK-LABEL: @uadd_u128x4
402 #[no_mangle]
403 pub unsafe fn uadd_u128x4(x: u128x4, y: u128x4) -> u128x4 {
404     // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.uadd.sat.v4i128(<4 x i128> %{{x|_3}}, <4 x i128> %{{y|_4}})
405     simd_saturating_add(x, y)
406 }
407
408
409
410
411
412 // CHECK-LABEL: @ssub_i8x2
413 #[no_mangle]
414 pub unsafe fn ssub_i8x2(x: i8x2, y: i8x2) -> i8x2 {
415     // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %{{x|_3}}, <2 x i8> %{{y|_4}})
416     simd_saturating_sub(x, y)
417 }
418
419 // CHECK-LABEL: @ssub_i8x4
420 #[no_mangle]
421 pub unsafe fn ssub_i8x4(x: i8x4, y: i8x4) -> i8x4 {
422     // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.ssub.sat.v4i8(<4 x i8> %{{x|_3}}, <4 x i8> %{{y|_4}})
423     simd_saturating_sub(x, y)
424 }
425
426 // CHECK-LABEL: @ssub_i8x8
427 #[no_mangle]
428 pub unsafe fn ssub_i8x8(x: i8x8, y: i8x8) -> i8x8 {
429     // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.ssub.sat.v8i8(<8 x i8> %{{x|_3}}, <8 x i8> %{{y|_4}})
430     simd_saturating_sub(x, y)
431 }
432
433 // CHECK-LABEL: @ssub_i8x16
434 #[no_mangle]
435 pub unsafe fn ssub_i8x16(x: i8x16, y: i8x16) -> i8x16 {
436     // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.ssub.sat.v16i8(<16 x i8> %{{x|_3}}, <16 x i8> %{{y|_4}})
437     simd_saturating_sub(x, y)
438 }
439
440 // CHECK-LABEL: @ssub_i8x32
441 #[no_mangle]
442 pub unsafe fn ssub_i8x32(x: i8x32, y: i8x32) -> i8x32 {
443     // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.ssub.sat.v32i8(<32 x i8> %{{x|_3}}, <32 x i8> %{{y|_4}})
444     simd_saturating_sub(x, y)
445 }
446
447 // CHECK-LABEL: @ssub_i8x64
448 #[no_mangle]
449 pub unsafe fn ssub_i8x64(x: i8x64, y: i8x64) -> i8x64 {
450     // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.ssub.sat.v64i8(<64 x i8> %{{x|_3}}, <64 x i8> %{{y|_4}})
451     simd_saturating_sub(x, y)
452 }
453
454 // CHECK-LABEL: @ssub_i16x2
455 #[no_mangle]
456 pub unsafe fn ssub_i16x2(x: i16x2, y: i16x2) -> i16x2 {
457     // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.ssub.sat.v2i16(<2 x i16> %{{x|_3}}, <2 x i16> %{{y|_4}})
458     simd_saturating_sub(x, y)
459 }
460
461 // CHECK-LABEL: @ssub_i16x4
462 #[no_mangle]
463 pub unsafe fn ssub_i16x4(x: i16x4, y: i16x4) -> i16x4 {
464     // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.ssub.sat.v4i16(<4 x i16> %{{x|_3}}, <4 x i16> %{{y|_4}})
465     simd_saturating_sub(x, y)
466 }
467
468 // CHECK-LABEL: @ssub_i16x8
469 #[no_mangle]
470 pub unsafe fn ssub_i16x8(x: i16x8, y: i16x8) -> i16x8 {
471     // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.ssub.sat.v8i16(<8 x i16> %{{x|_3}}, <8 x i16> %{{y|_4}})
472     simd_saturating_sub(x, y)
473 }
474
475 // CHECK-LABEL: @ssub_i16x16
476 #[no_mangle]
477 pub unsafe fn ssub_i16x16(x: i16x16, y: i16x16) -> i16x16 {
478     // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.ssub.sat.v16i16(<16 x i16> %{{x|_3}}, <16 x i16> %{{y|_4}})
479     simd_saturating_sub(x, y)
480 }
481
482 // CHECK-LABEL: @ssub_i16x32
483 #[no_mangle]
484 pub unsafe fn ssub_i16x32(x: i16x32, y: i16x32) -> i16x32 {
485     // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.ssub.sat.v32i16(<32 x i16> %{{x|_3}}, <32 x i16> %{{y|_4}})
486     simd_saturating_sub(x, y)
487 }
488
489 // CHECK-LABEL: @ssub_i32x2
490 #[no_mangle]
491 pub unsafe fn ssub_i32x2(x: i32x2, y: i32x2) -> i32x2 {
492     // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.ssub.sat.v2i32(<2 x i32> %{{x|_3}}, <2 x i32> %{{y|_4}})
493     simd_saturating_sub(x, y)
494 }
495
496 // CHECK-LABEL: @ssub_i32x4
497 #[no_mangle]
498 pub unsafe fn ssub_i32x4(x: i32x4, y: i32x4) -> i32x4 {
499     // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %{{x|_3}}, <4 x i32> %{{y|_4}})
500     simd_saturating_sub(x, y)
501 }
502
503 // CHECK-LABEL: @ssub_i32x8
504 #[no_mangle]
505 pub unsafe fn ssub_i32x8(x: i32x8, y: i32x8) -> i32x8 {
506     // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.ssub.sat.v8i32(<8 x i32> %{{x|_3}}, <8 x i32> %{{y|_4}})
507     simd_saturating_sub(x, y)
508 }
509
510 // CHECK-LABEL: @ssub_i32x16
511 #[no_mangle]
512 pub unsafe fn ssub_i32x16(x: i32x16, y: i32x16) -> i32x16 {
513     // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.ssub.sat.v16i32(<16 x i32> %{{x|_3}}, <16 x i32> %{{y|_4}})
514     simd_saturating_sub(x, y)
515 }
516
517 // CHECK-LABEL: @ssub_i64x2
518 #[no_mangle]
519 pub unsafe fn ssub_i64x2(x: i64x2, y: i64x2) -> i64x2 {
520     // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.ssub.sat.v2i64(<2 x i64> %{{x|_3}}, <2 x i64> %{{y|_4}})
521     simd_saturating_sub(x, y)
522 }
523
524 // CHECK-LABEL: @ssub_i64x4
525 #[no_mangle]
526 pub unsafe fn ssub_i64x4(x: i64x4, y: i64x4) -> i64x4 {
527     // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.ssub.sat.v4i64(<4 x i64> %{{x|_3}}, <4 x i64> %{{y|_4}})
528     simd_saturating_sub(x, y)
529 }
530
531 // CHECK-LABEL: @ssub_i64x8
532 #[no_mangle]
533 pub unsafe fn ssub_i64x8(x: i64x8, y: i64x8) -> i64x8 {
534     // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.ssub.sat.v8i64(<8 x i64> %{{x|_3}}, <8 x i64> %{{y|_4}})
535     simd_saturating_sub(x, y)
536 }
537
538 // CHECK-LABEL: @ssub_i128x2
539 #[no_mangle]
540 pub unsafe fn ssub_i128x2(x: i128x2, y: i128x2) -> i128x2 {
541     // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.ssub.sat.v2i128(<2 x i128> %{{x|_3}}, <2 x i128> %{{y|_4}})
542     simd_saturating_sub(x, y)
543 }
544
545 // CHECK-LABEL: @ssub_i128x4
546 #[no_mangle]
547 pub unsafe fn ssub_i128x4(x: i128x4, y: i128x4) -> i128x4 {
548     // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.ssub.sat.v4i128(<4 x i128> %{{x|_3}}, <4 x i128> %{{y|_4}})
549     simd_saturating_sub(x, y)
550 }
551
552
553
554 // CHECK-LABEL: @usub_u8x2
555 #[no_mangle]
556 pub unsafe fn usub_u8x2(x: u8x2, y: u8x2) -> u8x2 {
557     // CHECK: %{{[0-9]+}} = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %{{x|_3}}, <2 x i8> %{{y|_4}})
558     simd_saturating_sub(x, y)
559 }
560
561 // CHECK-LABEL: @usub_u8x4
562 #[no_mangle]
563 pub unsafe fn usub_u8x4(x: u8x4, y: u8x4) -> u8x4 {
564     // CHECK: %{{[0-9]+}} = call <4 x i8> @llvm.usub.sat.v4i8(<4 x i8> %{{x|_3}}, <4 x i8> %{{y|_4}})
565     simd_saturating_sub(x, y)
566 }
567
568 // CHECK-LABEL: @usub_u8x8
569 #[no_mangle]
570 pub unsafe fn usub_u8x8(x: u8x8, y: u8x8) -> u8x8 {
571     // CHECK: %{{[0-9]+}} = call <8 x i8> @llvm.usub.sat.v8i8(<8 x i8> %{{x|_3}}, <8 x i8> %{{y|_4}})
572     simd_saturating_sub(x, y)
573 }
574
575 // CHECK-LABEL: @usub_u8x16
576 #[no_mangle]
577 pub unsafe fn usub_u8x16(x: u8x16, y: u8x16) -> u8x16 {
578     // CHECK: %{{[0-9]+}} = call <16 x i8> @llvm.usub.sat.v16i8(<16 x i8> %{{x|_3}}, <16 x i8> %{{y|_4}})
579     simd_saturating_sub(x, y)
580 }
581
582 // CHECK-LABEL: @usub_u8x32
583 #[no_mangle]
584 pub unsafe fn usub_u8x32(x: u8x32, y: u8x32) -> u8x32 {
585     // CHECK: %{{[0-9]+}} = call <32 x i8> @llvm.usub.sat.v32i8(<32 x i8> %{{x|_3}}, <32 x i8> %{{y|_4}})
586     simd_saturating_sub(x, y)
587 }
588
589 // CHECK-LABEL: @usub_u8x64
590 #[no_mangle]
591 pub unsafe fn usub_u8x64(x: u8x64, y: u8x64) -> u8x64 {
592     // CHECK: %{{[0-9]+}} = call <64 x i8> @llvm.usub.sat.v64i8(<64 x i8> %{{x|_3}}, <64 x i8> %{{y|_4}})
593     simd_saturating_sub(x, y)
594 }
595
596 // CHECK-LABEL: @usub_u16x2
597 #[no_mangle]
598 pub unsafe fn usub_u16x2(x: u16x2, y: u16x2) -> u16x2 {
599     // CHECK: %{{[0-9]+}} = call <2 x i16> @llvm.usub.sat.v2i16(<2 x i16> %{{x|_3}}, <2 x i16> %{{y|_4}})
600     simd_saturating_sub(x, y)
601 }
602
603 // CHECK-LABEL: @usub_u16x4
604 #[no_mangle]
605 pub unsafe fn usub_u16x4(x: u16x4, y: u16x4) -> u16x4 {
606     // CHECK: %{{[0-9]+}} = call <4 x i16> @llvm.usub.sat.v4i16(<4 x i16> %{{x|_3}}, <4 x i16> %{{y|_4}})
607     simd_saturating_sub(x, y)
608 }
609
610 // CHECK-LABEL: @usub_u16x8
611 #[no_mangle]
612 pub unsafe fn usub_u16x8(x: u16x8, y: u16x8) -> u16x8 {
613     // CHECK: %{{[0-9]+}} = call <8 x i16> @llvm.usub.sat.v8i16(<8 x i16> %{{x|_3}}, <8 x i16> %{{y|_4}})
614     simd_saturating_sub(x, y)
615 }
616
617 // CHECK-LABEL: @usub_u16x16
618 #[no_mangle]
619 pub unsafe fn usub_u16x16(x: u16x16, y: u16x16) -> u16x16 {
620     // CHECK: %{{[0-9]+}} = call <16 x i16> @llvm.usub.sat.v16i16(<16 x i16> %{{x|_3}}, <16 x i16> %{{y|_4}})
621     simd_saturating_sub(x, y)
622 }
623
624 // CHECK-LABEL: @usub_u16x32
625 #[no_mangle]
626 pub unsafe fn usub_u16x32(x: u16x32, y: u16x32) -> u16x32 {
627     // CHECK: %{{[0-9]+}} = call <32 x i16> @llvm.usub.sat.v32i16(<32 x i16> %{{x|_3}}, <32 x i16> %{{y|_4}})
628     simd_saturating_sub(x, y)
629 }
630
631 // CHECK-LABEL: @usub_u32x2
632 #[no_mangle]
633 pub unsafe fn usub_u32x2(x: u32x2, y: u32x2) -> u32x2 {
634     // CHECK: %{{[0-9]+}} = call <2 x i32> @llvm.usub.sat.v2i32(<2 x i32> %{{x|_3}}, <2 x i32> %{{y|_4}})
635     simd_saturating_sub(x, y)
636 }
637
638 // CHECK-LABEL: @usub_u32x4
639 #[no_mangle]
640 pub unsafe fn usub_u32x4(x: u32x4, y: u32x4) -> u32x4 {
641     // CHECK: %{{[0-9]+}} = call <4 x i32> @llvm.usub.sat.v4i32(<4 x i32> %{{x|_3}}, <4 x i32> %{{y|_4}})
642     simd_saturating_sub(x, y)
643 }
644
645 // CHECK-LABEL: @usub_u32x8
646 #[no_mangle]
647 pub unsafe fn usub_u32x8(x: u32x8, y: u32x8) -> u32x8 {
648     // CHECK: %{{[0-9]+}} = call <8 x i32> @llvm.usub.sat.v8i32(<8 x i32> %{{x|_3}}, <8 x i32> %{{y|_4}})
649     simd_saturating_sub(x, y)
650 }
651
652 // CHECK-LABEL: @usub_u32x16
653 #[no_mangle]
654 pub unsafe fn usub_u32x16(x: u32x16, y: u32x16) -> u32x16 {
655     // CHECK: %{{[0-9]+}} = call <16 x i32> @llvm.usub.sat.v16i32(<16 x i32> %{{x|_3}}, <16 x i32> %{{y|_4}})
656     simd_saturating_sub(x, y)
657 }
658
659 // CHECK-LABEL: @usub_u64x2
660 #[no_mangle]
661 pub unsafe fn usub_u64x2(x: u64x2, y: u64x2) -> u64x2 {
662     // CHECK: %{{[0-9]+}} = call <2 x i64> @llvm.usub.sat.v2i64(<2 x i64> %{{x|_3}}, <2 x i64> %{{y|_4}})
663     simd_saturating_sub(x, y)
664 }
665
666 // CHECK-LABEL: @usub_u64x4
667 #[no_mangle]
668 pub unsafe fn usub_u64x4(x: u64x4, y: u64x4) -> u64x4 {
669     // CHECK: %{{[0-9]+}} = call <4 x i64> @llvm.usub.sat.v4i64(<4 x i64> %{{x|_3}}, <4 x i64> %{{y|_4}})
670     simd_saturating_sub(x, y)
671 }
672
673 // CHECK-LABEL: @usub_u64x8
674 #[no_mangle]
675 pub unsafe fn usub_u64x8(x: u64x8, y: u64x8) -> u64x8 {
676     // CHECK: %{{[0-9]+}} = call <8 x i64> @llvm.usub.sat.v8i64(<8 x i64> %{{x|_3}}, <8 x i64> %{{y|_4}})
677     simd_saturating_sub(x, y)
678 }
679
680 // CHECK-LABEL: @usub_u128x2
681 #[no_mangle]
682 pub unsafe fn usub_u128x2(x: u128x2, y: u128x2) -> u128x2 {
683     // CHECK: %{{[0-9]+}} = call <2 x i128> @llvm.usub.sat.v2i128(<2 x i128> %{{x|_3}}, <2 x i128> %{{y|_4}})
684     simd_saturating_sub(x, y)
685 }
686
687 // CHECK-LABEL: @usub_u128x4
688 #[no_mangle]
689 pub unsafe fn usub_u128x4(x: u128x4, y: u128x4) -> u128x4 {
690     // CHECK: %{{[0-9]+}} = call <4 x i128> @llvm.usub.sat.v4i128(<4 x i128> %{{x|_3}}, <4 x i128> %{{y|_4}})
691     simd_saturating_sub(x, y)
692 }