llvm.org GIT mirror llvm / ad4da63
[InstructionSimplify] Add support for saturating add/sub Add support for saturating add/sub in InstructionSimplify. In particular, the following simplifications are supported: sat(X + 0) -> X sat(X + undef) -> -1 sat(X uadd MAX) -> MAX (and commutative variants) sat(X - 0) -> X sat(X - X) -> 0 sat(X - undef) -> 0 sat(undef - X) -> 0 sat(0 usub X) -> 0 sat(X usub MAX) -> 0 Patch by: @nikic (Nikita Popov) Differential Revision: https://reviews.llvm.org/D54532 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347330 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 10 months ago
2 changed file(s) with 78 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
49114911 if (match(Op0, m_Undef()) || match(Op1, m_Undef()))
49124912 return Constant::getNullValue(ReturnType);
49134913 break;
4914 case Intrinsic::uadd_sat:
4915 // sat(MAX + X) -> MAX
4916 // sat(X + MAX) -> MAX
4917 if (match(Op0, m_AllOnes()) || match(Op1, m_AllOnes()))
4918 return Constant::getAllOnesValue(ReturnType);
4919 LLVM_FALLTHROUGH;
4920 case Intrinsic::sadd_sat:
4921 // sat(X + undef) -> -1
4922 // sat(undef + X) -> -1
4923 // For unsigned: Assume undef is MAX, thus we saturate to MAX (-1).
4924 // For signed: Assume undef is ~X, in which case X + ~X = -1.
4925 if (match(Op0, m_Undef()) || match(Op1, m_Undef()))
4926 return Constant::getAllOnesValue(ReturnType);
4927
4928 // X + 0 -> X
4929 if (match(Op1, m_Zero()))
4930 return Op0;
4931 // 0 + X -> X
4932 if (match(Op0, m_Zero()))
4933 return Op1;
4934 break;
4935 case Intrinsic::usub_sat:
4936 // sat(0 - X) -> 0, sat(X - MAX) -> 0
4937 if (match(Op0, m_Zero()) || match(Op1, m_AllOnes()))
4938 return Constant::getNullValue(ReturnType);
4939 LLVM_FALLTHROUGH;
4940 case Intrinsic::ssub_sat:
4941 // X - X -> 0, X - undef -> 0, undef - X -> 0
4942 if (Op0 == Op1 || match(Op0, m_Undef()) || match(Op1, m_Undef()))
4943 return Constant::getNullValue(ReturnType);
4944 // X - 0 -> X
4945 if (match(Op1, m_Zero()))
4946 return Op0;
4947 break;
49144948 case Intrinsic::load_relative:
49154949 if (auto *C0 = dyn_cast(Op0))
49164950 if (auto *C1 = dyn_cast(Op1))
1515
1616 define i8 @uadd_scalar_0(i8 %a) {
1717 ; CHECK-LABEL: @uadd_scalar_0(
18 ; CHECK-NEXT: [[X1:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 0)
19 ; CHECK-NEXT: ret i8 [[X1]]
18 ; CHECK-NEXT: ret i8 [[A:%.*]]
2019 ;
2120 %x1 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 0)
2221 ret i8 %x1
2423
2524 define <2 x i8> @uadd_vector_0(<2 x i8> %a) {
2625 ; CHECK-LABEL: @uadd_vector_0(
27 ; CHECK-NEXT: [[X1V:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> zeroinitializer)
28 ; CHECK-NEXT: ret <2 x i8> [[X1V]]
26 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
2927 ;
3028 %x1v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %a, <2 x i8> zeroinitializer)
3129 ret <2 x i8> %x1v
3331
3432 define i3 @uadd_scalar_0_commute(i3 %a) {
3533 ; CHECK-LABEL: @uadd_scalar_0_commute(
36 ; CHECK-NEXT: [[X2:%.*]] = call i3 @llvm.uadd.sat.i3(i3 0, i3 [[A:%.*]])
37 ; CHECK-NEXT: ret i3 [[X2]]
34 ; CHECK-NEXT: ret i3 [[A:%.*]]
3835 ;
3936 %x2 = call i3 @llvm.uadd.sat.i3(i3 0, i3 %a)
4037 ret i3 %x2
4239
4340 define <2 x i8> @uadd_vector_0_commute(<2 x i8> %a) {
4441 ; CHECK-LABEL: @uadd_vector_0_commute(
45 ; CHECK-NEXT: [[X2V:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> , <2 x i8> [[A:%.*]])
46 ; CHECK-NEXT: ret <2 x i8> [[X2V]]
42 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
4743 ;
4844 %x2v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> , <2 x i8> %a)
4945 ret <2 x i8> %x2v
5147
5248 define i8 @uadd_scalar_maxval(i8 %a) {
5349 ; CHECK-LABEL: @uadd_scalar_maxval(
54 ; CHECK-NEXT: [[X3:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 -1)
55 ; CHECK-NEXT: ret i8 [[X3]]
50 ; CHECK-NEXT: ret i8 -1
5651 ;
5752 %x3 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 255)
5853 ret i8 %x3
6055
6156 define <2 x i9> @uadd_vector_maxval(<2 x i9> %a) {
6257 ; CHECK-LABEL: @uadd_vector_maxval(
63 ; CHECK-NEXT: [[X3V:%.*]] = call <2 x i9> @llvm.uadd.sat.v2i9(<2 x i9> [[A:%.*]], <2 x i9> )
64 ; CHECK-NEXT: ret <2 x i9> [[X3V]]
58 ; CHECK-NEXT: ret <2 x i9>
6559 ;
6660 %x3v = call <2 x i9> @llvm.uadd.sat.v2i9(<2 x i9> %a, <2 x i9> )
6761 ret <2 x i9> %x3v
6963
7064 define i3 @uadd_scalar_maxval_commute(i3 %a) {
7165 ; CHECK-LABEL: @uadd_scalar_maxval_commute(
72 ; CHECK-NEXT: [[X4:%.*]] = call i3 @llvm.uadd.sat.i3(i3 -1, i3 [[A:%.*]])
73 ; CHECK-NEXT: ret i3 [[X4]]
66 ; CHECK-NEXT: ret i3 -1
7467 ;
7568 %x4 = call i3 @llvm.uadd.sat.i3(i3 7, i3 %a)
7669 ret i3 %x4
7871
7972 define <2 x i8> @uadd_vector_maxval_commute(<2 x i8> %a) {
8073 ; CHECK-LABEL: @uadd_vector_maxval_commute(
81 ; CHECK-NEXT: [[X4V:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> , <2 x i8> [[A:%.*]])
82 ; CHECK-NEXT: ret <2 x i8> [[X4V]]
74 ; CHECK-NEXT: ret <2 x i8>
8375 ;
8476 %x4v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> , <2 x i8> %a)
8577 ret <2 x i8> %x4v
8779
8880 define i8 @uadd_scalar_undef(i8 %a) {
8981 ; CHECK-LABEL: @uadd_scalar_undef(
90 ; CHECK-NEXT: [[X5:%.*]] = call i8 @llvm.uadd.sat.i8(i8 [[A:%.*]], i8 undef)
91 ; CHECK-NEXT: ret i8 [[X5]]
82 ; CHECK-NEXT: ret i8 -1
9283 ;
9384 %x5 = call i8 @llvm.uadd.sat.i8(i8 %a, i8 undef)
9485 ret i8 %x5
9687
9788 define <2 x i8> @uadd_vector_undef(<2 x i8> %a) {
9889 ; CHECK-LABEL: @uadd_vector_undef(
99 ; CHECK-NEXT: [[X5V:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> undef)
100 ; CHECK-NEXT: ret <2 x i8> [[X5V]]
90 ; CHECK-NEXT: ret <2 x i8>
10191 ;
10292 %x5v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> %a, <2 x i8> )
10393 ret <2 x i8> %x5v
10595
10696 define i8 @uadd_scalar_undef_commute(i8 %a) {
10797 ; CHECK-LABEL: @uadd_scalar_undef_commute(
108 ; CHECK-NEXT: [[X6:%.*]] = call i8 @llvm.uadd.sat.i8(i8 undef, i8 [[A:%.*]])
109 ; CHECK-NEXT: ret i8 [[X6]]
98 ; CHECK-NEXT: ret i8 -1
11099 ;
111100 %x6 = call i8 @llvm.uadd.sat.i8(i8 undef, i8 %a)
112101 ret i8 %x6
114103
115104 define <2 x i8> @uadd_vector_undef_commute(<2 x i8> %a) {
116105 ; CHECK-LABEL: @uadd_vector_undef_commute(
117 ; CHECK-NEXT: [[X5V:%.*]] = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> undef, <2 x i8> [[A:%.*]])
118 ; CHECK-NEXT: ret <2 x i8> [[X5V]]
106 ; CHECK-NEXT: ret <2 x i8>
119107 ;
120108 %x5v = call <2 x i8> @llvm.uadd.sat.v2i8(<2 x i8> undef, <2 x i8> %a)
121109 ret <2 x i8> %x5v
123111
124112 define i8 @sadd_scalar_0(i8 %a) {
125113 ; CHECK-LABEL: @sadd_scalar_0(
126 ; CHECK-NEXT: [[Y1:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 0)
127 ; CHECK-NEXT: ret i8 [[Y1]]
114 ; CHECK-NEXT: ret i8 [[A:%.*]]
128115 ;
129116 %y1 = call i8 @llvm.sadd.sat.i8(i8 %a, i8 0)
130117 ret i8 %y1
132119
133120 define <2 x i8> @sadd_vector_0(<2 x i8> %a) {
134121 ; CHECK-LABEL: @sadd_vector_0(
135 ; CHECK-NEXT: [[Y1V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> )
136 ; CHECK-NEXT: ret <2 x i8> [[Y1V]]
122 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
137123 ;
138124 %y1v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %a, <2 x i8> )
139125 ret <2 x i8> %y1v
141127
142128 define i8 @sadd_scalar_0_commute(i8 %a) {
143129 ; CHECK-LABEL: @sadd_scalar_0_commute(
144 ; CHECK-NEXT: [[Y2:%.*]] = call i8 @llvm.sadd.sat.i8(i8 0, i8 [[A:%.*]])
145 ; CHECK-NEXT: ret i8 [[Y2]]
130 ; CHECK-NEXT: ret i8 [[A:%.*]]
146131 ;
147132 %y2 = call i8 @llvm.sadd.sat.i8(i8 0, i8 %a)
148133 ret i8 %y2
150135
151136 define <2 x i8> @sadd_vector_0_commute(<2 x i8> %a) {
152137 ; CHECK-LABEL: @sadd_vector_0_commute(
153 ; CHECK-NEXT: [[Y2V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> zeroinitializer, <2 x i8> [[A:%.*]])
154 ; CHECK-NEXT: ret <2 x i8> [[Y2V]]
138 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
155139 ;
156140 %y2v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> zeroinitializer, <2 x i8> %a)
157141 ret <2 x i8> %y2v
195179
196180 define i8 @sadd_scalar_undef(i8 %a) {
197181 ; CHECK-LABEL: @sadd_scalar_undef(
198 ; CHECK-NEXT: [[Y5:%.*]] = call i8 @llvm.sadd.sat.i8(i8 [[A:%.*]], i8 undef)
199 ; CHECK-NEXT: ret i8 [[Y5]]
182 ; CHECK-NEXT: ret i8 -1
200183 ;
201184 %y5 = call i8 @llvm.sadd.sat.i8(i8 %a, i8 undef)
202185 ret i8 %y5
204187
205188 define <2 x i8> @sadd_vector_undef(<2 x i8> %a) {
206189 ; CHECK-LABEL: @sadd_vector_undef(
207 ; CHECK-NEXT: [[Y5V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> undef)
208 ; CHECK-NEXT: ret <2 x i8> [[Y5V]]
190 ; CHECK-NEXT: ret <2 x i8>
209191 ;
210192 %y5v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> %a, <2 x i8> undef)
211193 ret <2 x i8> %y5v
213195
214196 define i8 @sadd_scalar_undef_commute(i8 %a) {
215197 ; CHECK-LABEL: @sadd_scalar_undef_commute(
216 ; CHECK-NEXT: [[Y6:%.*]] = call i8 @llvm.sadd.sat.i8(i8 undef, i8 [[A:%.*]])
217 ; CHECK-NEXT: ret i8 [[Y6]]
198 ; CHECK-NEXT: ret i8 -1
218199 ;
219200 %y6 = call i8 @llvm.sadd.sat.i8(i8 undef, i8 %a)
220201 ret i8 %y6
222203
223204 define <2 x i8> @sadd_vector_undef_commute(<2 x i8> %a) {
224205 ; CHECK-LABEL: @sadd_vector_undef_commute(
225 ; CHECK-NEXT: [[Y6V:%.*]] = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> undef, <2 x i8> [[A:%.*]])
226 ; CHECK-NEXT: ret <2 x i8> [[Y6V]]
206 ; CHECK-NEXT: ret <2 x i8>
227207 ;
228208 %y6v = call <2 x i8> @llvm.sadd.sat.v2i8(<2 x i8> undef, <2 x i8> %a)
229209 ret <2 x i8> %y6v
231211
232212 define i8 @usub_scalar_0(i8 %a) {
233213 ; CHECK-LABEL: @usub_scalar_0(
234 ; CHECK-NEXT: [[X1:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 0)
235 ; CHECK-NEXT: ret i8 [[X1]]
214 ; CHECK-NEXT: ret i8 [[A:%.*]]
236215 ;
237216 %x1 = call i8 @llvm.usub.sat.i8(i8 %a, i8 0)
238217 ret i8 %x1
240219
241220 define <2 x i8> @usub_vector_0(<2 x i8> %a) {
242221 ; CHECK-LABEL: @usub_vector_0(
243 ; CHECK-NEXT: [[X1V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> zeroinitializer)
244 ; CHECK-NEXT: ret <2 x i8> [[X1V]]
222 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
245223 ;
246224 %x1v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> )
247225 ret <2 x i8> %x1v
249227
250228 define i8 @usub_scalar_0_commute(i8 %a) {
251229 ; CHECK-LABEL: @usub_scalar_0_commute(
252 ; CHECK-NEXT: [[X2:%.*]] = call i8 @llvm.usub.sat.i8(i8 0, i8 [[A:%.*]])
253 ; CHECK-NEXT: ret i8 [[X2]]
230 ; CHECK-NEXT: ret i8 0
254231 ;
255232 %x2 = call i8 @llvm.usub.sat.i8(i8 0, i8 %a)
256233 ret i8 %x2
258235
259236 define <2 x i8> @usub_vector_0_commute(<2 x i8> %a) {
260237 ; CHECK-LABEL: @usub_vector_0_commute(
261 ; CHECK-NEXT: [[X2V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> zeroinitializer, <2 x i8> [[A:%.*]])
262 ; CHECK-NEXT: ret <2 x i8> [[X2V]]
238 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
263239 ;
264240 %x2v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> , <2 x i8> %a)
265241 ret <2 x i8> %x2v
267243
268244 define i8 @usub_scalar_maxval(i8 %a) {
269245 ; CHECK-LABEL: @usub_scalar_maxval(
270 ; CHECK-NEXT: [[X3:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 -1)
271 ; CHECK-NEXT: ret i8 [[X3]]
246 ; CHECK-NEXT: ret i8 0
272247 ;
273248 %x3 = call i8 @llvm.usub.sat.i8(i8 %a, i8 255)
274249 ret i8 %x3
276251
277252 define <2 x i8> @usub_vector_maxval(<2 x i8> %a) {
278253 ; CHECK-LABEL: @usub_vector_maxval(
279 ; CHECK-NEXT: [[X3V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> )
280 ; CHECK-NEXT: ret <2 x i8> [[X3V]]
254 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
281255 ;
282256 %x3v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> )
283257 ret <2 x i8> %x3v
285259
286260 define i8 @usub_scalar_undef(i8 %a) {
287261 ; CHECK-LABEL: @usub_scalar_undef(
288 ; CHECK-NEXT: [[X4:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 undef)
289 ; CHECK-NEXT: ret i8 [[X4]]
262 ; CHECK-NEXT: ret i8 0
290263 ;
291264 %x4 = call i8 @llvm.usub.sat.i8(i8 %a, i8 undef)
292265 ret i8 %x4
294267
295268 define <2 x i8> @usub_vector_undef(<2 x i8> %a) {
296269 ; CHECK-LABEL: @usub_vector_undef(
297 ; CHECK-NEXT: [[X4V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> )
298 ; CHECK-NEXT: ret <2 x i8> [[X4V]]
299 ;
300 %x4v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> )
270 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
271 ;
272 %x4v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> )
301273 ret <2 x i8> %x4v
302274 }
303275
304276 define i8 @usub_scalar_undef_commute(i8 %a) {
305277 ; CHECK-LABEL: @usub_scalar_undef_commute(
306 ; CHECK-NEXT: [[X5:%.*]] = call i8 @llvm.usub.sat.i8(i8 undef, i8 [[A:%.*]])
307 ; CHECK-NEXT: ret i8 [[X5]]
278 ; CHECK-NEXT: ret i8 0
308279 ;
309280 %x5 = call i8 @llvm.usub.sat.i8(i8 undef, i8 %a)
310281 ret i8 %x5
312283
313284 define <2 x i8> @usub_vector_undef_commute(<2 x i8> %a) {
314285 ; CHECK-LABEL: @usub_vector_undef_commute(
315 ; CHECK-NEXT: [[X5V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> undef)
316 ; CHECK-NEXT: ret <2 x i8> [[X5V]]
317 ;
318 %x5v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> )
286 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
287 ;
288 %x5v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> , <2 x i8> %a)
319289 ret <2 x i8> %x5v
320290 }
321291
322292 define i8 @usub_scalar_same(i8 %a) {
323293 ; CHECK-LABEL: @usub_scalar_same(
324 ; CHECK-NEXT: [[X6:%.*]] = call i8 @llvm.usub.sat.i8(i8 [[A:%.*]], i8 [[A]])
325 ; CHECK-NEXT: ret i8 [[X6]]
294 ; CHECK-NEXT: ret i8 0
326295 ;
327296 %x6 = call i8 @llvm.usub.sat.i8(i8 %a, i8 %a)
328297 ret i8 %x6
330299
331300 define <2 x i8> @usub_vector_same(<2 x i8> %a) {
332301 ; CHECK-LABEL: @usub_vector_same(
333 ; CHECK-NEXT: [[X6V:%.*]] = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> [[A]])
334 ; CHECK-NEXT: ret <2 x i8> [[X6V]]
302 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
335303 ;
336304 %x6v = call <2 x i8> @llvm.usub.sat.v2i8(<2 x i8> %a, <2 x i8> %a)
337305 ret <2 x i8> %x6v
339307
340308 define i8 @ssub_scalar_0(i8 %a) {
341309 ; CHECK-LABEL: @ssub_scalar_0(
342 ; CHECK-NEXT: [[Y1:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 0)
343 ; CHECK-NEXT: ret i8 [[Y1]]
310 ; CHECK-NEXT: ret i8 [[A:%.*]]
344311 ;
345312 %y1 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 0)
346313 ret i8 %y1
348315
349316 define <2 x i8> @ssub_vector_0(<2 x i8> %a) {
350317 ; CHECK-LABEL: @ssub_vector_0(
351 ; CHECK-NEXT: [[Y1V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> zeroinitializer)
352 ; CHECK-NEXT: ret <2 x i8> [[Y1V]]
318 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
353319 ;
354320 %y1v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> )
355321 ret <2 x i8> %y1v
393359
394360 define i8 @ssub_scalar_undef(i8 %a) {
395361 ; CHECK-LABEL: @ssub_scalar_undef(
396 ; CHECK-NEXT: [[Y4:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 undef)
397 ; CHECK-NEXT: ret i8 [[Y4]]
362 ; CHECK-NEXT: ret i8 0
398363 ;
399364 %y4 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 undef)
400365 ret i8 %y4
402367
403368 define <2 x i8> @ssub_vector_undef(<2 x i8> %a) {
404369 ; CHECK-LABEL: @ssub_vector_undef(
405 ; CHECK-NEXT: [[Y4V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> undef)
406 ; CHECK-NEXT: ret <2 x i8> [[Y4V]]
370 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
407371 ;
408372 %y4v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> undef)
409373 ret <2 x i8> %y4v
411375
412376 define i8 @ssub_scalar_undef_commute(i8 %a) {
413377 ; CHECK-LABEL: @ssub_scalar_undef_commute(
414 ; CHECK-NEXT: [[Y5:%.*]] = call i8 @llvm.ssub.sat.i8(i8 undef, i8 [[A:%.*]])
415 ; CHECK-NEXT: ret i8 [[Y5]]
378 ; CHECK-NEXT: ret i8 0
416379 ;
417380 %y5 = call i8 @llvm.ssub.sat.i8(i8 undef, i8 %a)
418381 ret i8 %y5
420383
421384 define <2 x i8> @ssub_vector_undef_commute(<2 x i8> %a) {
422385 ; CHECK-LABEL: @ssub_vector_undef_commute(
423 ; CHECK-NEXT: [[Y5V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> undef, <2 x i8> [[A:%.*]])
424 ; CHECK-NEXT: ret <2 x i8> [[Y5V]]
386 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
425387 ;
426388 %y5v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> , <2 x i8> %a)
427389 ret <2 x i8> %y5v
429391
430392 define i8 @ssub_scalar_same(i8 %a) {
431393 ; CHECK-LABEL: @ssub_scalar_same(
432 ; CHECK-NEXT: [[Y6:%.*]] = call i8 @llvm.ssub.sat.i8(i8 [[A:%.*]], i8 [[A]])
433 ; CHECK-NEXT: ret i8 [[Y6]]
394 ; CHECK-NEXT: ret i8 0
434395 ;
435396 %y6 = call i8 @llvm.ssub.sat.i8(i8 %a, i8 %a)
436397 ret i8 %y6
438399
439400 define <2 x i8> @ssub_vector_same(<2 x i8> %a) {
440401 ; CHECK-LABEL: @ssub_vector_same(
441 ; CHECK-NEXT: [[Y6V:%.*]] = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> [[A:%.*]], <2 x i8> [[A]])
442 ; CHECK-NEXT: ret <2 x i8> [[Y6V]]
402 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
443403 ;
444404 %y6v = call <2 x i8> @llvm.ssub.sat.v2i8(<2 x i8> %a, <2 x i8> %a)
445405 ret <2 x i8> %y6v