1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 declare i3 @llvm.uadd.sat.i3(i3, i3)
5 declare i8 @llvm.uadd.sat.i8(i8, i8)
6 declare <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8>, <2 x i8>)
7 declare <2 x i9> @llvm.uadd.sat.v2i9(<2 x i9>, <2 x i9>)
9 declare i8 @llvm.sadd.sat.i8(i8, i8)
10 declare <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8>, <2 x i8>)
12 declare i8 @llvm.usub.sat.i8(i8, i8)
13 declare i8 @llvm.ssub.sat.i8(i8, i8)
14 declare <2 x i8> @llvm.usub.sat.v2i8(<2 x i8>, <2 x i8>)
15 declare <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8>, <2 x i8>)
17 define i8 @uadd_scalar_0(i8 %a) {
18 ; CHECK-LABEL: @uadd_scalar_0(
19 ; CHECK-NEXT: ret i8 [[A:%.*]]
21 %x1 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 0)
25 define <2 x i8> @uadd_vector_0(<2 x i8> %a) {
26 ; CHECK-LABEL: @uadd_vector_0(
27 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
29 %x1v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %a, <2 x i8> zeroinitializer)
33 define i3 @uadd_scalar_0_commute(i3 %a) {
34 ; CHECK-LABEL: @uadd_scalar_0_commute(
35 ; CHECK-NEXT: ret i3 [[A:%.*]]
37 %x2 = call i3 @llvm.uadd.sat.i3(i3 0, i3 %a)
41 define <2 x i8> @uadd_vector_0_commute(<2 x i8> %a) {
42 ; CHECK-LABEL: @uadd_vector_0_commute(
43 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
45 %x2v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 0, i8 undef>, <2 x i8> %a)
49 define i8 @uadd_scalar_maxval(i8 %a) {
50 ; CHECK-LABEL: @uadd_scalar_maxval(
51 ; CHECK-NEXT: ret i8 -1
53 %x3 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 255)
57 define <2 x i9> @uadd_vector_maxval(<2 x i9> %a) {
58 ; CHECK-LABEL: @uadd_vector_maxval(
59 ; CHECK-NEXT: ret <2 x i9> <i9 -1, i9 -1>
61 %x3v = call <2 x i9> @llvm.uadd.sat.v2i9(<2 x i9> %a, <2 x i9> <i9 511, i9 511>)
65 define i3 @uadd_scalar_maxval_commute(i3 %a) {
66 ; CHECK-LABEL: @uadd_scalar_maxval_commute(
67 ; CHECK-NEXT: ret i3 -1
69 %x4 = call i3 @llvm.uadd.sat.i3(i3 7, i3 %a)
73 define <2 x i8> @uadd_vector_maxval_commute(<2 x i8> %a) {
74 ; CHECK-LABEL: @uadd_vector_maxval_commute(
75 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
77 %x4v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> <i8 255, i8 255>, <2 x i8> %a)
81 define i8 @uadd_scalar_undef(i8 %a) {
82 ; CHECK-LABEL: @uadd_scalar_undef(
83 ; CHECK-NEXT: ret i8 -1
85 %x5 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 undef)
89 define <2 x i8> @uadd_vector_undef(<2 x i8> %a) {
90 ; CHECK-LABEL: @uadd_vector_undef(
91 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
93 %x5v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 undef, i8 undef>)
97 define i8 @uadd_scalar_undef_commute(i8 %a) {
98 ; CHECK-LABEL: @uadd_scalar_undef_commute(
99 ; CHECK-NEXT: ret i8 -1
101 %x6 = call i8 @llvm.uadd.sat.i8(i8 undef, i8 %a)
105 define <2 x i8> @uadd_vector_undef_commute(<2 x i8> %a) {
106 ; CHECK-LABEL: @uadd_vector_undef_commute(
107 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
109 %x5v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> undef, <2 x i8> %a)
113 define i8 @sadd_scalar_0(i8 %a) {
114 ; CHECK-LABEL: @sadd_scalar_0(
115 ; CHECK-NEXT: ret i8 [[A:%.*]]
117 %y1 = call i8 @llvm.sadd.sat.i8(i8 %a, i8 0)
121 define <2 x i8> @sadd_vector_0(<2 x i8> %a) {
122 ; CHECK-LABEL: @sadd_vector_0(
123 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
125 %y1v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 undef, i8 0>)
129 define i8 @sadd_scalar_0_commute(i8 %a) {
130 ; CHECK-LABEL: @sadd_scalar_0_commute(
131 ; CHECK-NEXT: ret i8 [[A:%.*]]
133 %y2 = call i8 @llvm.sadd.sat.i8(i8 0, i8 %a)
137 define <2 x i8> @sadd_vector_0_commute(<2 x i8> %a) {
138 ; CHECK-LABEL: @sadd_vector_0_commute(
139 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
141 %y2v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> zeroinitializer, <2 x i8> %a)
145 define i8 @sadd_scalar_maxval(i8 %a) {
146 ; CHECK-LABEL: @sadd_scalar_maxval(
147 ; CHECK-NEXT: [[Y3:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 127)
148 ; CHECK-NEXT: ret i8 [[Y3]]
150 %y3 = call i8 @llvm.sadd.sat.i8(i8 %a, i8 127)
154 define <2 x i8> @sadd_vector_maxval(<2 x i8> %a) {
155 ; CHECK-LABEL: @sadd_vector_maxval(
156 ; CHECK-NEXT: [[Y3V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> <i8 127, i8 127>)
157 ; CHECK-NEXT: ret <2 x i8> [[Y3V]]
159 %y3v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 127, i8 127>)
163 define i8 @sadd_scalar_maxval_commute(i8 %a) {
164 ; CHECK-LABEL: @sadd_scalar_maxval_commute(
165 ; CHECK-NEXT: [[Y4:%.*]] = call i8 @llvm.sadd.sat.i8(i8 127, i8 [[A:%.*]])
166 ; CHECK-NEXT: ret i8 [[Y4]]
168 %y4 = call i8 @llvm.sadd.sat.i8(i8 127, i8 %a)
172 define <2 x i8> @sadd_vector_maxval_commute(<2 x i8> %a) {
173 ; CHECK-LABEL: @sadd_vector_maxval_commute(
174 ; CHECK-NEXT: [[Y4V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> [[A:%.*]])
175 ; CHECK-NEXT: ret <2 x i8> [[Y4V]]
177 %y4v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> <i8 undef, i8 127>, <2 x i8> %a)
181 define i8 @sadd_scalar_undef(i8 %a) {
182 ; CHECK-LABEL: @sadd_scalar_undef(
183 ; CHECK-NEXT: ret i8 -1
185 %y5 = call i8 @llvm.sadd.sat.i8(i8 %a, i8 undef)
189 define <2 x i8> @sadd_vector_undef(<2 x i8> %a) {
190 ; CHECK-LABEL: @sadd_vector_undef(
191 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
193 %y5v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %a, <2 x i8> undef)
197 define i8 @sadd_scalar_undef_commute(i8 %a) {
198 ; CHECK-LABEL: @sadd_scalar_undef_commute(
199 ; CHECK-NEXT: ret i8 -1
201 %y6 = call i8 @llvm.sadd.sat.i8(i8 undef, i8 %a)
205 define <2 x i8> @sadd_vector_undef_commute(<2 x i8> %a) {
206 ; CHECK-LABEL: @sadd_vector_undef_commute(
207 ; CHECK-NEXT: ret <2 x i8> <i8 -1, i8 -1>
209 %y6v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> undef, <2 x i8> %a)
213 define i8 @usub_scalar_0(i8 %a) {
214 ; CHECK-LABEL: @usub_scalar_0(
215 ; CHECK-NEXT: ret i8 [[A:%.*]]
217 %x1 = call i8 @llvm.usub.sat.i8(i8 %a, i8 0)
221 define <2 x i8> @usub_vector_0(<2 x i8> %a) {
222 ; CHECK-LABEL: @usub_vector_0(
223 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
225 %x1v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 0, i8 0>)
229 define i8 @usub_scalar_0_commute(i8 %a) {
230 ; CHECK-LABEL: @usub_scalar_0_commute(
231 ; CHECK-NEXT: ret i8 0
233 %x2 = call i8 @llvm.usub.sat.i8(i8 0, i8 %a)
237 define <2 x i8> @usub_vector_0_commute(<2 x i8> %a) {
238 ; CHECK-LABEL: @usub_vector_0_commute(
239 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
241 %x2v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 0, i8 0>, <2 x i8> %a)
245 define i8 @usub_scalar_maxval(i8 %a) {
246 ; CHECK-LABEL: @usub_scalar_maxval(
247 ; CHECK-NEXT: ret i8 0
249 %x3 = call i8 @llvm.usub.sat.i8(i8 %a, i8 255)
253 define <2 x i8> @usub_vector_maxval(<2 x i8> %a) {
254 ; CHECK-LABEL: @usub_vector_maxval(
255 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
257 %x3v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 255, i8 255>)
261 define i8 @usub_scalar_undef(i8 %a) {
262 ; CHECK-LABEL: @usub_scalar_undef(
263 ; CHECK-NEXT: ret i8 0
265 %x4 = call i8 @llvm.usub.sat.i8(i8 %a, i8 undef)
269 define <2 x i8> @usub_vector_undef(<2 x i8> %a) {
270 ; CHECK-LABEL: @usub_vector_undef(
271 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
273 %x4v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 undef, i8 undef>)
277 define i8 @usub_scalar_undef_commute(i8 %a) {
278 ; CHECK-LABEL: @usub_scalar_undef_commute(
279 ; CHECK-NEXT: ret i8 0
281 %x5 = call i8 @llvm.usub.sat.i8(i8 undef, i8 %a)
285 define <2 x i8> @usub_vector_undef_commute(<2 x i8> %a) {
286 ; CHECK-LABEL: @usub_vector_undef_commute(
287 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
289 %x5v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> <i8 undef, i8 undef>, <2 x i8> %a)
293 define i8 @usub_scalar_same(i8 %a) {
294 ; CHECK-LABEL: @usub_scalar_same(
295 ; CHECK-NEXT: ret i8 0
297 %x6 = call i8 @llvm.usub.sat.i8(i8 %a, i8 %a)
301 define <2 x i8> @usub_vector_same(<2 x i8> %a) {
302 ; CHECK-LABEL: @usub_vector_same(
303 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
305 %x6v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> %a)
309 define i8 @ssub_scalar_0(i8 %a) {
310 ; CHECK-LABEL: @ssub_scalar_0(
311 ; CHECK-NEXT: ret i8 [[A:%.*]]
313 %y1 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 0)
317 define <2 x i8> @ssub_vector_0(<2 x i8> %a) {
318 ; CHECK-LABEL: @ssub_vector_0(
319 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
321 %y1v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 0, i8 0>)
325 define i8 @ssub_scalar_0_commute(i8 %a) {
326 ; CHECK-LABEL: @ssub_scalar_0_commute(
327 ; CHECK-NEXT: [[Y2:%.*]] = call i8 @llvm.ssub.sat.i8(i8 0, i8 [[A:%.*]])
328 ; CHECK-NEXT: ret i8 [[Y2]]
330 %y2 = call i8 @llvm.ssub.sat.i8(i8 0, i8 %a)
334 define <2 x i8> @ssub_vector_0_commute(<2 x i8> %a) {
335 ; CHECK-LABEL: @ssub_vector_0_commute(
336 ; CHECK-NEXT: [[Y2V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> zeroinitializer, <2 x i8> [[A:%.*]])
337 ; CHECK-NEXT: ret <2 x i8> [[Y2V]]
339 %y2v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 0, i8 0>, <2 x i8> %a)
343 define i8 @ssub_scalar_maxval(i8 %a) {
344 ; CHECK-LABEL: @ssub_scalar_maxval(
345 ; CHECK-NEXT: [[Y3:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 127)
346 ; CHECK-NEXT: ret i8 [[Y3]]
348 %y3 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 127)
352 define <2 x i8> @ssub_vector_maxval(<2 x i8> %a) {
353 ; CHECK-LABEL: @ssub_vector_maxval(
354 ; CHECK-NEXT: [[Y3V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> <i8 127, i8 127>)
355 ; CHECK-NEXT: ret <2 x i8> [[Y3V]]
357 %y3v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> <i8 127, i8 127>)
361 define i8 @ssub_scalar_undef(i8 %a) {
362 ; CHECK-LABEL: @ssub_scalar_undef(
363 ; CHECK-NEXT: ret i8 0
365 %y4 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 undef)
369 define <2 x i8> @ssub_vector_undef(<2 x i8> %a) {
370 ; CHECK-LABEL: @ssub_vector_undef(
371 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
373 %y4v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> undef)
377 define i8 @ssub_scalar_undef_commute(i8 %a) {
378 ; CHECK-LABEL: @ssub_scalar_undef_commute(
379 ; CHECK-NEXT: ret i8 0
381 %y5 = call i8 @llvm.ssub.sat.i8(i8 undef, i8 %a)
385 define <2 x i8> @ssub_vector_undef_commute(<2 x i8> %a) {
386 ; CHECK-LABEL: @ssub_vector_undef_commute(
387 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
389 %y5v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> <i8 undef, i8 undef>, <2 x i8> %a)
393 define i8 @ssub_scalar_same(i8 %a) {
394 ; CHECK-LABEL: @ssub_scalar_same(
395 ; CHECK-NEXT: ret i8 0
397 %y6 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 %a)
401 define <2 x i8> @ssub_vector_same(<2 x i8> %a) {
402 ; CHECK-LABEL: @ssub_vector_same(
403 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
405 %y6v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> %a)
409 define i1 @uadd_icmp_op0_known(i8 %a) {
410 ; CHECK-LABEL: @uadd_icmp_op0_known(
411 ; CHECK-NEXT: ret i1 true
413 %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
414 %c = icmp uge i8 %b, 10
418 define i1 @uadd_icmp_op0_unknown(i8 %a) {
419 ; CHECK-LABEL: @uadd_icmp_op0_unknown(
420 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 10, i8 [[A:%.*]])
421 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
422 ; CHECK-NEXT: ret i1 [[C]]
424 %b = call i8 @llvm.uadd.sat.i8(i8 10, i8 %a)
425 %c = icmp ugt i8 %b, 10
429 define i1 @uadd_icmp_op1_known(i8 %a) {
430 ; CHECK-LABEL: @uadd_icmp_op1_known(
431 ; CHECK-NEXT: ret i1 true
433 %b = call i8 @llvm.uadd.sat.i8(i8 %a, i8 10)
434 %c = icmp uge i8 %b, 10
438 define i1 @uadd_icmp_op1_unknown(i8 %a) {
439 ; CHECK-LABEL: @uadd_icmp_op1_unknown(
440 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 10)
441 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[B]], 10
442 ; CHECK-NEXT: ret i1 [[C]]
444 %b = call i8 @llvm.uadd.sat.i8(i8 %a, i8 10)
445 %c = icmp ugt i8 %b, 10
449 define i1 @sadd_icmp_op0_pos_known(i8 %a) {
450 ; CHECK-LABEL: @sadd_icmp_op0_pos_known(
451 ; CHECK-NEXT: ret i1 true
453 %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
454 %c = icmp sge i8 %b, -118
458 define i1 @sadd_icmp_op0_pos_unknown(i8 %a) {
459 ; CHECK-LABEL: @sadd_icmp_op0_pos_unknown(
460 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 10, i8 [[A:%.*]])
461 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
462 ; CHECK-NEXT: ret i1 [[C]]
464 %b = call i8 @llvm.sadd.sat.i8(i8 10, i8 %a)
465 %c = icmp sgt i8 %b, -118
469 define i1 @sadd_icmp_op0_neg_known(i8 %a) {
470 ; CHECK-LABEL: @sadd_icmp_op0_neg_known(
471 ; CHECK-NEXT: ret i1 true
473 %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
474 %c = icmp sle i8 %b, 117
478 define i1 @sadd_icmp_op0_neg_unknown(i8 %a) {
479 ; CHECK-LABEL: @sadd_icmp_op0_neg_unknown(
480 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 -10, i8 [[A:%.*]])
481 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
482 ; CHECK-NEXT: ret i1 [[C]]
484 %b = call i8 @llvm.sadd.sat.i8(i8 -10, i8 %a)
485 %c = icmp slt i8 %b, 117
489 define i1 @sadd_icmp_op1_pos_known(i8 %a) {
490 ; CHECK-LABEL: @sadd_icmp_op1_pos_known(
491 ; CHECK-NEXT: ret i1 true
493 %b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 10)
494 %c = icmp sge i8 %b, -118
498 define i1 @sadd_icmp_op1_pos_unknown(i8 %a) {
499 ; CHECK-LABEL: @sadd_icmp_op1_pos_unknown(
500 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 10)
501 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
502 ; CHECK-NEXT: ret i1 [[C]]
504 %b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 10)
505 %c = icmp sgt i8 %b, -118
509 define i1 @sadd_icmp_op1_neg_known(i8 %a) {
510 ; CHECK-LABEL: @sadd_icmp_op1_neg_known(
511 ; CHECK-NEXT: ret i1 true
513 %b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 -10)
514 %c = icmp sle i8 %b, 117
518 define i1 @sadd_icmp_op1_neg_unknown(i8 %a) {
519 ; CHECK-LABEL: @sadd_icmp_op1_neg_unknown(
520 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 -10)
521 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
522 ; CHECK-NEXT: ret i1 [[C]]
524 %b = call i8 @llvm.sadd.sat.i8(i8 %a, i8 -10)
525 %c = icmp slt i8 %b, 117
529 define i1 @usub_icmp_op0_known(i8 %a) {
530 ; CHECK-LABEL: @usub_icmp_op0_known(
531 ; CHECK-NEXT: ret i1 true
533 %b = call i8 @llvm.usub.sat.i8(i8 10, i8 %a)
534 %c = icmp ule i8 %b, 10
538 define i1 @usub_icmp_op0_unknown(i8 %a) {
539 ; CHECK-LABEL: @usub_icmp_op0_unknown(
540 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.usub.sat.i8(i8 10, i8 [[A:%.*]])
541 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[B]], 10
542 ; CHECK-NEXT: ret i1 [[C]]
544 %b = call i8 @llvm.usub.sat.i8(i8 10, i8 %a)
545 %c = icmp ult i8 %b, 10
549 define i1 @usub_icmp_op1_known(i8 %a) {
550 ; CHECK-LABEL: @usub_icmp_op1_known(
551 ; CHECK-NEXT: ret i1 true
553 %b = call i8 @llvm.usub.sat.i8(i8 %a, i8 10)
554 %c = icmp ule i8 %b, 245
558 define i1 @usub_icmp_op1_unknown(i8 %a) {
559 ; CHECK-LABEL: @usub_icmp_op1_unknown(
560 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 10)
561 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[B]], -11
562 ; CHECK-NEXT: ret i1 [[C]]
564 %b = call i8 @llvm.usub.sat.i8(i8 %a, i8 10)
565 %c = icmp ult i8 %b, 245
569 define i1 @ssub_icmp_op0_pos_known(i8 %a) {
570 ; CHECK-LABEL: @ssub_icmp_op0_pos_known(
571 ; CHECK-NEXT: ret i1 true
573 %b = call i8 @llvm.ssub.sat.i8(i8 10, i8 %a)
574 %c = icmp sge i8 %b, -117
578 define i1 @ssub_icmp_op0_pos_unknown(i8 %a) {
579 ; CHECK-LABEL: @ssub_icmp_op0_pos_unknown(
580 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 10, i8 [[A:%.*]])
581 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -117
582 ; CHECK-NEXT: ret i1 [[C]]
584 %b = call i8 @llvm.ssub.sat.i8(i8 10, i8 %a)
585 %c = icmp sgt i8 %b, -117
589 define i1 @ssub_icmp_op0_neg_known(i8 %a) {
590 ; CHECK-LABEL: @ssub_icmp_op0_neg_known(
591 ; CHECK-NEXT: ret i1 true
593 %b = call i8 @llvm.ssub.sat.i8(i8 -10, i8 %a)
594 %c = icmp sle i8 %b, 118
598 define i1 @ssub_icmp_op0_neg_unknown(i8 %a) {
599 ; CHECK-LABEL: @ssub_icmp_op0_neg_unknown(
600 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 -10, i8 [[A:%.*]])
601 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 118
602 ; CHECK-NEXT: ret i1 [[C]]
604 %b = call i8 @llvm.ssub.sat.i8(i8 -10, i8 %a)
605 %c = icmp slt i8 %b, 118
609 ; Peculiar case: ssub.sat(0, x) is never signed min.
610 define i1 @ssub_icmp_op0_zero(i8 %a) {
611 ; CHECK-LABEL: @ssub_icmp_op0_zero(
612 ; CHECK-NEXT: ret i1 true
614 %b = call i8 @llvm.ssub.sat.i8(i8 0, i8 %a)
615 %c = icmp ne i8 %b, -128
619 define i1 @ssub_icmp_op1_pos_known(i8 %a) {
620 ; CHECK-LABEL: @ssub_icmp_op1_pos_known(
621 ; CHECK-NEXT: ret i1 true
623 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
624 %c = icmp sle i8 %b, 117
628 define i1 @ssub_icmp_op1_pos_unknown(i8 %a) {
629 ; CHECK-LABEL: @ssub_icmp_op1_pos_unknown(
630 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 10)
631 ; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[B]], 117
632 ; CHECK-NEXT: ret i1 [[C]]
634 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 10)
635 %c = icmp slt i8 %b, 117
639 define i1 @ssub_icmp_op1_neg_known(i8 %a) {
640 ; CHECK-LABEL: @ssub_icmp_op1_neg_known(
641 ; CHECK-NEXT: ret i1 true
643 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
644 %c = icmp sge i8 %b, -118
648 define i1 @ssub_icmp_op1_neg_unknown(i8 %a) {
649 ; CHECK-LABEL: @ssub_icmp_op1_neg_unknown(
650 ; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 -10)
651 ; CHECK-NEXT: [[C:%.*]] = icmp sgt i8 [[B]], -118
652 ; CHECK-NEXT: ret i1 [[C]]
654 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -10)
655 %c = icmp sgt i8 %b, -118
659 define i1 @ssub_icmp_op1_smin(i8 %a) {
660 ; CHECK-LABEL: @ssub_icmp_op1_smin(
661 ; CHECK-NEXT: ret i1 true
663 %b = call i8 @llvm.ssub.sat.i8(i8 %a, i8 -128)
664 %c = icmp sge i8 %b, 0