xref: /llvm-project/llvm/test/Transforms/InstSimplify/ConstProp/saturating-add-sub.ll (revision 38fffa630ee80163dc65e759392ad29798905679)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
3
4declare i8 @llvm.uadd.sat.i8(i8, i8)
5declare i8 @llvm.sadd.sat.i8(i8, i8)
6declare <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8>, <2 x i8>)
7declare <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8>, <2 x i8>)
8
9declare i8 @llvm.usub.sat.i8(i8, i8)
10declare i8 @llvm.ssub.sat.i8(i8, i8)
11declare <2 x i8> @llvm.usub.sat.v2i8(<2 x i8>, <2 x i8>)
12declare <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8>, <2 x i8>)
13
14define i8 @test_uadd_scalar_no_sat() {
15; CHECK-LABEL: @test_uadd_scalar_no_sat(
16; CHECK-NEXT:    ret i8 30
17;
18  %x = call i8 @llvm.uadd.sat.i8(i8 10, i8 20)
19  ret i8 %x
20}
21
22define i8 @test_uadd_scalar_sat() {
23; CHECK-LABEL: @test_uadd_scalar_sat(
24; CHECK-NEXT:    ret i8 -1
25;
26  %x = call i8 @llvm.uadd.sat.i8(i8 250, i8 100)
27  ret i8 %x
28}
29
30define i8 @test_sadd_scalar_no_sat() {
31; CHECK-LABEL: @test_sadd_scalar_no_sat(
32; CHECK-NEXT:    ret i8 -10
33;
34  %x = call i8 @llvm.sadd.sat.i8(i8 10, i8 -20)
35  ret i8 %x
36}
37
38define i8 @test_sadd_scalar_sat_pos() {
39; CHECK-LABEL: @test_sadd_scalar_sat_pos(
40; CHECK-NEXT:    ret i8 127
41;
42  %x = call i8 @llvm.sadd.sat.i8(i8 120, i8 10)
43  ret i8 %x
44}
45
46define i8 @test_sadd_scalar_sat_neg() {
47; CHECK-LABEL: @test_sadd_scalar_sat_neg(
48; CHECK-NEXT:    ret i8 -128
49;
50  %x = call i8 @llvm.sadd.sat.i8(i8 -120, i8 -10)
51  ret i8 %x
52}
53
54define <2 x i8> @test_uadd_vector_no_sat(<2 x i8> %a) {
55; CHECK-LABEL: @test_uadd_vector_no_sat(
56; CHECK-NEXT:    ret <2 x i8> <i8 20, i8 30>
57;
58  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 15>, <2 x i8> <i8 10, i8 15>)
59  ret <2 x i8> %x
60}
61
62define <2 x i8> @test_uadd_vector_sat(<2 x i8> %a) {
63; CHECK-LABEL: @test_uadd_vector_sat(
64; CHECK-NEXT:    ret <2 x i8> splat (i8 -1)
65;
66  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 250, i8 100>)
67  ret <2 x i8> %x
68}
69
70define <2 x i8> @test_sadd_vector_no_sat(<2 x i8> %a) {
71; CHECK-LABEL: @test_sadd_vector_no_sat(
72; CHECK-NEXT:    ret <2 x i8> <i8 -10, i8 -30>
73;
74  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
75  ret <2 x i8> %x
76}
77
78define <2 x i8> @test_sadd_vector_sat_pos(<2 x i8> %a) {
79; CHECK-LABEL: @test_sadd_vector_sat_pos(
80; CHECK-NEXT:    ret <2 x i8> splat (i8 127)
81;
82  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 30, i8 120>)
83  ret <2 x i8> %x
84}
85
86define <2 x i8> @test_sadd_vector_sat_neg(<2 x i8> %a) {
87; CHECK-LABEL: @test_sadd_vector_sat_neg(
88; CHECK-NEXT:    ret <2 x i8> splat (i8 -128)
89;
90  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 -30, i8 -120>)
91  ret <2 x i8> %x
92}
93
94define i8 @test_usub_scalar_no_sat() {
95; CHECK-LABEL: @test_usub_scalar_no_sat(
96; CHECK-NEXT:    ret i8 10
97;
98  %x = call i8 @llvm.usub.sat.i8(i8 20, i8 10)
99  ret i8 %x
100}
101
102define i8 @test_usub_scalar_sat() {
103; CHECK-LABEL: @test_usub_scalar_sat(
104; CHECK-NEXT:    ret i8 0
105;
106  %x = call i8 @llvm.usub.sat.i8(i8 200, i8 250)
107  ret i8 %x
108}
109
110define i8 @test_ssub_scalar_no_sat() {
111; CHECK-LABEL: @test_ssub_scalar_no_sat(
112; CHECK-NEXT:    ret i8 -30
113;
114  %x = call i8 @llvm.ssub.sat.i8(i8 -10, i8 20)
115  ret i8 %x
116}
117
118define i8 @test_ssub_scalar_sat_pos() {
119; CHECK-LABEL: @test_ssub_scalar_sat_pos(
120; CHECK-NEXT:    ret i8 127
121;
122  %x = call i8 @llvm.ssub.sat.i8(i8 120, i8 -10)
123  ret i8 %x
124}
125
126define i8 @test_ssub_scalar_sat_neg() {
127; CHECK-LABEL: @test_ssub_scalar_sat_neg(
128; CHECK-NEXT:    ret i8 -128
129;
130  %x = call i8 @llvm.ssub.sat.i8(i8 -120, i8 10)
131  ret i8 %x
132}
133
134define <2 x i8> @test_usub_vector_no_sat(<2 x i8> %a) {
135; CHECK-LABEL: @test_usub_vector_no_sat(
136; CHECK-NEXT:    ret <2 x i8> <i8 10, i8 5>
137;
138  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 20, i8 15>, <2 x i8> <i8 10, i8 10>)
139  ret <2 x i8> %x
140}
141
142define <2 x i8> @test_usub_vector_sat(<2 x i8> %a) {
143; CHECK-LABEL: @test_usub_vector_sat(
144; CHECK-NEXT:    ret <2 x i8> zeroinitializer
145;
146  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 100, i8 200>, <2 x i8> <i8 150, i8 250>)
147  ret <2 x i8> %x
148}
149
150define <2 x i8> @test_ssub_vector_no_sat(<2 x i8> %a) {
151; CHECK-LABEL: @test_ssub_vector_no_sat(
152; CHECK-NEXT:    ret <2 x i8> <i8 30, i8 0>
153;
154  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 10, i8 -15>, <2 x i8> <i8 -20, i8 -15>)
155  ret <2 x i8> %x
156}
157
158define <2 x i8> @test_ssub_vector_sat_pos(<2 x i8> %a) {
159; CHECK-LABEL: @test_ssub_vector_sat_pos(
160; CHECK-NEXT:    ret <2 x i8> splat (i8 127)
161;
162  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 100, i8 10>, <2 x i8> <i8 -30, i8 -120>)
163  ret <2 x i8> %x
164}
165
166define <2 x i8> @test_ssub_vector_sat_neg(<2 x i8> %a) {
167; CHECK-LABEL: @test_ssub_vector_sat_neg(
168; CHECK-NEXT:    ret <2 x i8> splat (i8 -128)
169;
170  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 -100, i8 -10>, <2 x i8> <i8 30, i8 120>)
171  ret <2 x i8> %x
172}
173
174; Tests for undef handling
175
176define i8 @test_uadd_scalar_both_undef() {
177; CHECK-LABEL: @test_uadd_scalar_both_undef(
178; CHECK-NEXT:    ret i8 undef
179;
180  %x = call i8 @llvm.uadd.sat.i8(i8 undef, i8 undef)
181  ret i8 %x
182}
183
184define i8 @test_sadd_scalar_both_undef() {
185; CHECK-LABEL: @test_sadd_scalar_both_undef(
186; CHECK-NEXT:    ret i8 undef
187;
188  %x = call i8 @llvm.sadd.sat.i8(i8 undef, i8 undef)
189  ret i8 %x
190}
191
192define i8 @test_usub_scalar_both_undef() {
193; CHECK-LABEL: @test_usub_scalar_both_undef(
194; CHECK-NEXT:    ret i8 undef
195;
196  %x = call i8 @llvm.usub.sat.i8(i8 undef, i8 undef)
197  ret i8 %x
198}
199
200define i8 @test_ssub_scalar_both_undef() {
201; CHECK-LABEL: @test_ssub_scalar_both_undef(
202; CHECK-NEXT:    ret i8 undef
203;
204  %x = call i8 @llvm.ssub.sat.i8(i8 undef, i8 undef)
205  ret i8 %x
206}
207
208define i8 @test_uadd_scalar_op2_undef() {
209; CHECK-LABEL: @test_uadd_scalar_op2_undef(
210; CHECK-NEXT:    ret i8 -1
211;
212  %x = call i8 @llvm.uadd.sat.i8(i8 10, i8 undef)
213  ret i8 %x
214}
215
216define i8 @test_sadd_scalar_op1_undef() {
217; CHECK-LABEL: @test_sadd_scalar_op1_undef(
218; CHECK-NEXT:    ret i8 -1
219;
220  %x = call i8 @llvm.sadd.sat.i8(i8 undef, i8 10)
221  ret i8 %x
222}
223
224define i8 @test_usub_scalar_op2_undef() {
225; CHECK-LABEL: @test_usub_scalar_op2_undef(
226; CHECK-NEXT:    ret i8 0
227;
228  %x = call i8 @llvm.usub.sat.i8(i8 10, i8 undef)
229  ret i8 %x
230}
231
232define i8 @test_usub_scalar_op1_undef() {
233; CHECK-LABEL: @test_usub_scalar_op1_undef(
234; CHECK-NEXT:    ret i8 0
235;
236  %x = call i8 @llvm.usub.sat.i8(i8 undef, i8 10)
237  ret i8 %x
238}
239
240define <2 x i8> @test_uadd_vector_both_undef_splat() {
241; CHECK-LABEL: @test_uadd_vector_both_undef_splat(
242; CHECK-NEXT:    ret <2 x i8> undef
243;
244  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> undef, <2 x i8> undef)
245  ret <2 x i8> %x
246}
247
248define <2 x i8> @test_sadd_vector_both_undef_splat() {
249; CHECK-LABEL: @test_sadd_vector_both_undef_splat(
250; CHECK-NEXT:    ret <2 x i8> undef
251;
252  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> undef, <2 x i8> undef)
253  ret <2 x i8> %x
254}
255
256define <2 x i8> @test_usub_vector_both_undef_splat() {
257; CHECK-LABEL: @test_usub_vector_both_undef_splat(
258; CHECK-NEXT:    ret <2 x i8> undef
259;
260  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> undef, <2 x i8> undef)
261  ret <2 x i8> %x
262}
263
264define <2 x i8> @test_ssub_vector_both_undef_splat() {
265; CHECK-LABEL: @test_ssub_vector_both_undef_splat(
266; CHECK-NEXT:    ret <2 x i8> undef
267;
268  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> undef, <2 x i8> undef)
269  ret <2 x i8> %x
270}
271
272define <2 x i8> @test_uadd_vector_op2_undef_splat() {
273; CHECK-LABEL: @test_uadd_vector_op2_undef_splat(
274; CHECK-NEXT:    ret <2 x i8> splat (i8 -1)
275;
276  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> undef)
277  ret <2 x i8> %x
278}
279
280define <2 x i8> @test_sadd_vector_op1_undef_splat() {
281; CHECK-LABEL: @test_sadd_vector_op1_undef_splat(
282; CHECK-NEXT:    ret <2 x i8> splat (i8 -1)
283;
284  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> undef, <2 x i8> <i8 10, i8 20>)
285  ret <2 x i8> %x
286}
287
288define <2 x i8> @test_usub_vector_op2_undef_splat() {
289; CHECK-LABEL: @test_usub_vector_op2_undef_splat(
290; CHECK-NEXT:    ret <2 x i8> zeroinitializer
291;
292  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> undef)
293  ret <2 x i8> %x
294}
295
296define <2 x i8> @test_ssub_vector_op1_undef_splat() {
297; CHECK-LABEL: @test_ssub_vector_op1_undef_splat(
298; CHECK-NEXT:    ret <2 x i8> zeroinitializer
299;
300  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> undef, <2 x i8> <i8 10, i8 20>)
301  ret <2 x i8> %x
302}
303
304define <2 x i8> @test_uadd_vector_op2_undef_mix1() {
305; CHECK-LABEL: @test_uadd_vector_op2_undef_mix1(
306; CHECK-NEXT:    ret <2 x i8> <i8 30, i8 undef>
307;
308  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 undef>, <2 x i8> <i8 20, i8 undef>)
309  ret <2 x i8> %x
310}
311
312define <2 x i8> @test_uadd_vector_op2_undef_mix2() {
313; CHECK-LABEL: @test_uadd_vector_op2_undef_mix2(
314; CHECK-NEXT:    ret <2 x i8> splat (i8 -1)
315;
316  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 undef>, <2 x i8> <i8 undef, i8 20>)
317  ret <2 x i8> %x
318}
319
320define <2 x i8> @test_sadd_vector_op1_undef_mix1() {
321; CHECK-LABEL: @test_sadd_vector_op1_undef_mix1(
322; CHECK-NEXT:    ret <2 x i8> <i8 undef, i8 30>
323;
324  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 undef, i8 10>, <2 x i8> <i8 undef, i8 20>)
325  ret <2 x i8> %x
326}
327
328define <2 x i8> @test_sadd_vector_op1_undef_mix2() {
329; CHECK-LABEL: @test_sadd_vector_op1_undef_mix2(
330; CHECK-NEXT:    ret <2 x i8> splat (i8 -1)
331;
332  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 undef, i8 10>, <2 x i8> <i8 20, i8 undef>)
333  ret <2 x i8> %x
334}
335
336define <2 x i8> @test_usub_vector_op2_undef_mix1() {
337; CHECK-LABEL: @test_usub_vector_op2_undef_mix1(
338; CHECK-NEXT:    ret <2 x i8> <i8 0, i8 undef>
339;
340  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 undef>, <2 x i8> <i8 20, i8 undef>)
341  ret <2 x i8> %x
342}
343
344define <2 x i8> @test_usub_vector_op2_undef_mix2() {
345; CHECK-LABEL: @test_usub_vector_op2_undef_mix2(
346; CHECK-NEXT:    ret <2 x i8> zeroinitializer
347;
348  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 undef>, <2 x i8> <i8 undef, i8 20>)
349  ret <2 x i8> %x
350}
351
352define <2 x i8> @test_ssub_vector_op1_undef_mix1() {
353; CHECK-LABEL: @test_ssub_vector_op1_undef_mix1(
354; CHECK-NEXT:    ret <2 x i8> <i8 undef, i8 -10>
355;
356  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 undef, i8 10>, <2 x i8> <i8 undef, i8 20>)
357  ret <2 x i8> %x
358}
359
360define <2 x i8> @test_ssub_vector_op1_undef_mix2() {
361; CHECK-LABEL: @test_ssub_vector_op1_undef_mix2(
362; CHECK-NEXT:    ret <2 x i8> zeroinitializer
363;
364  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 undef, i8 10>, <2 x i8> <i8 20, i8 undef>)
365  ret <2 x i8> %x
366}
367
368; Tests for poison handling
369
370define i8 @test_uadd_scalar_both_poison() {
371; CHECK-LABEL: @test_uadd_scalar_both_poison(
372; CHECK-NEXT:    ret i8 poison
373;
374  %x = call i8 @llvm.uadd.sat.i8(i8 poison, i8 poison)
375  ret i8 %x
376}
377
378define i8 @test_sadd_scalar_both_poison() {
379; CHECK-LABEL: @test_sadd_scalar_both_poison(
380; CHECK-NEXT:    ret i8 poison
381;
382  %x = call i8 @llvm.sadd.sat.i8(i8 poison, i8 poison)
383  ret i8 %x
384}
385
386define i8 @test_usub_scalar_both_poison() {
387; CHECK-LABEL: @test_usub_scalar_both_poison(
388; CHECK-NEXT:    ret i8 poison
389;
390  %x = call i8 @llvm.usub.sat.i8(i8 poison, i8 poison)
391  ret i8 %x
392}
393
394define i8 @test_ssub_scalar_both_poison() {
395; CHECK-LABEL: @test_ssub_scalar_both_poison(
396; CHECK-NEXT:    ret i8 poison
397;
398  %x = call i8 @llvm.ssub.sat.i8(i8 poison, i8 poison)
399  ret i8 %x
400}
401
402define i8 @test_uadd_scalar_op2_poison() {
403; CHECK-LABEL: @test_uadd_scalar_op2_poison(
404; CHECK-NEXT:    ret i8 poison
405;
406  %x = call i8 @llvm.uadd.sat.i8(i8 10, i8 poison)
407  ret i8 %x
408}
409
410define i8 @test_sadd_scalar_op1_poison() {
411; CHECK-LABEL: @test_sadd_scalar_op1_poison(
412; CHECK-NEXT:    ret i8 poison
413;
414  %x = call i8 @llvm.sadd.sat.i8(i8 poison, i8 10)
415  ret i8 %x
416}
417
418define i8 @test_usub_scalar_op2_poison() {
419; CHECK-LABEL: @test_usub_scalar_op2_poison(
420; CHECK-NEXT:    ret i8 poison
421;
422  %x = call i8 @llvm.usub.sat.i8(i8 10, i8 poison)
423  ret i8 %x
424}
425
426define i8 @test_usub_scalar_op1_poison() {
427; CHECK-LABEL: @test_usub_scalar_op1_poison(
428; CHECK-NEXT:    ret i8 poison
429;
430  %x = call i8 @llvm.usub.sat.i8(i8 poison, i8 10)
431  ret i8 %x
432}
433
434define <2 x i8> @test_uadd_vector_both_poison_splat() {
435; CHECK-LABEL: @test_uadd_vector_both_poison_splat(
436; CHECK-NEXT:    ret <2 x i8> poison
437;
438  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
439  ret <2 x i8> %x
440}
441
442define <2 x i8> @test_sadd_vector_both_poison_splat() {
443; CHECK-LABEL: @test_sadd_vector_both_poison_splat(
444; CHECK-NEXT:    ret <2 x i8> poison
445;
446  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
447  ret <2 x i8> %x
448}
449
450define <2 x i8> @test_usub_vector_both_poison_splat() {
451; CHECK-LABEL: @test_usub_vector_both_poison_splat(
452; CHECK-NEXT:    ret <2 x i8> poison
453;
454  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
455  ret <2 x i8> %x
456}
457
458define <2 x i8> @test_ssub_vector_both_poison_splat() {
459; CHECK-LABEL: @test_ssub_vector_both_poison_splat(
460; CHECK-NEXT:    ret <2 x i8> poison
461;
462  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> poison, <2 x i8> poison)
463  ret <2 x i8> %x
464}
465
466define <2 x i8> @test_uadd_vector_op2_poison_splat() {
467; CHECK-LABEL: @test_uadd_vector_op2_poison_splat(
468; CHECK-NEXT:    ret <2 x i8> poison
469;
470  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> poison)
471  ret <2 x i8> %x
472}
473
474define <2 x i8> @test_sadd_vector_op1_poison_splat() {
475; CHECK-LABEL: @test_sadd_vector_op1_poison_splat(
476; CHECK-NEXT:    ret <2 x i8> poison
477;
478  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> poison, <2 x i8> <i8 10, i8 20>)
479  ret <2 x i8> %x
480}
481
482define <2 x i8> @test_usub_vector_op2_poison_splat() {
483; CHECK-LABEL: @test_usub_vector_op2_poison_splat(
484; CHECK-NEXT:    ret <2 x i8> poison
485;
486  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 20>, <2 x i8> poison)
487  ret <2 x i8> %x
488}
489
490define <2 x i8> @test_ssub_vector_op1_poison_splat() {
491; CHECK-LABEL: @test_ssub_vector_op1_poison_splat(
492; CHECK-NEXT:    ret <2 x i8> poison
493;
494  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> poison, <2 x i8> <i8 10, i8 20>)
495  ret <2 x i8> %x
496}
497
498define <2 x i8> @test_uadd_vector_op2_poison_mix1() {
499; CHECK-LABEL: @test_uadd_vector_op2_poison_mix1(
500; CHECK-NEXT:    ret <2 x i8> <i8 30, i8 poison>
501;
502  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 20, i8 poison>)
503  ret <2 x i8> %x
504}
505
506define <2 x i8> @test_uadd_vector_op2_poison_mix2() {
507; CHECK-LABEL: @test_uadd_vector_op2_poison_mix2(
508; CHECK-NEXT:    ret <2 x i8> poison
509;
510  %x = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 poison, i8 20>)
511  ret <2 x i8> %x
512}
513
514define <2 x i8> @test_sadd_vector_op1_poison_mix1() {
515; CHECK-LABEL: @test_sadd_vector_op1_poison_mix1(
516; CHECK-NEXT:    ret <2 x i8> <i8 poison, i8 30>
517;
518  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 poison, i8 20>)
519  ret <2 x i8> %x
520}
521
522define <2 x i8> @test_sadd_vector_op1_poison_mix2() {
523; CHECK-LABEL: @test_sadd_vector_op1_poison_mix2(
524; CHECK-NEXT:    ret <2 x i8> poison
525;
526  %x = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 20, i8 poison>)
527  ret <2 x i8> %x
528}
529
530define <2 x i8> @test_usub_vector_op2_poison_mix1() {
531; CHECK-LABEL: @test_usub_vector_op2_poison_mix1(
532; CHECK-NEXT:    ret <2 x i8> <i8 0, i8 poison>
533;
534  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 20, i8 poison>)
535  ret <2 x i8> %x
536}
537
538define <2 x i8> @test_usub_vector_op2_poison_mix2() {
539; CHECK-LABEL: @test_usub_vector_op2_poison_mix2(
540; CHECK-NEXT:    ret <2 x i8> poison
541;
542  %x = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 10, i8 poison>, <2 x i8> <i8 poison, i8 20>)
543  ret <2 x i8> %x
544}
545
546define <2 x i8> @test_ssub_vector_op1_poison_mix1() {
547; CHECK-LABEL: @test_ssub_vector_op1_poison_mix1(
548; CHECK-NEXT:    ret <2 x i8> <i8 poison, i8 -10>
549;
550  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 poison, i8 20>)
551  ret <2 x i8> %x
552}
553
554define <2 x i8> @test_ssub_vector_op1_poison_mix2() {
555; CHECK-LABEL: @test_ssub_vector_op1_poison_mix2(
556; CHECK-NEXT:    ret <2 x i8> poison
557;
558  %x = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 poison, i8 10>, <2 x i8> <i8 20, i8 poison>)
559  ret <2 x i8> %x
560}
561