1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v,+d -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+v,+d -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
8 define <8 x i8> @sabd_8b_as_16b(<8 x i8> %a, <8 x i8> %b) {
10 ; CHECK-LABEL: sabd_8b_as_16b:
12 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
13 ; CHECK-NEXT: vmin.vv v10, v8, v9
14 ; CHECK-NEXT: vmax.vv v8, v8, v9
15 ; CHECK-NEXT: vsub.vv v8, v8, v10
17 %a.sext = sext <8 x i8> %a to <8 x i16>
18 %b.sext = sext <8 x i8> %b to <8 x i16>
19 %sub = sub <8 x i16> %a.sext, %b.sext
20 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
21 %trunc = trunc <8 x i16> %abs to <8 x i8>
25 define <8 x i8> @sabd_8b_as_32b(<8 x i8> %a, <8 x i8> %b) {
27 ; CHECK-LABEL: sabd_8b_as_32b:
29 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
30 ; CHECK-NEXT: vmin.vv v10, v8, v9
31 ; CHECK-NEXT: vmax.vv v8, v8, v9
32 ; CHECK-NEXT: vsub.vv v8, v8, v10
34 %a.sext = sext <8 x i8> %a to <8 x i32>
35 %b.sext = sext <8 x i8> %b to <8 x i32>
36 %sub = sub <8 x i32> %a.sext, %b.sext
37 %abs = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %sub, i1 true)
38 %trunc = trunc <8 x i32> %abs to <8 x i8>
42 define <16 x i8> @sabd_16b(<16 x i8> %a, <16 x i8> %b) {
44 ; CHECK-LABEL: sabd_16b:
46 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
47 ; CHECK-NEXT: vmin.vv v10, v8, v9
48 ; CHECK-NEXT: vmax.vv v8, v8, v9
49 ; CHECK-NEXT: vsub.vv v8, v8, v10
51 %a.sext = sext <16 x i8> %a to <16 x i16>
52 %b.sext = sext <16 x i8> %b to <16 x i16>
53 %sub = sub <16 x i16> %a.sext, %b.sext
54 %abs = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %sub, i1 true)
55 %trunc = trunc <16 x i16> %abs to <16 x i8>
59 define <4 x i16> @sabd_4h(<4 x i16> %a, <4 x i16> %b) {
61 ; CHECK-LABEL: sabd_4h:
63 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
64 ; CHECK-NEXT: vmin.vv v10, v8, v9
65 ; CHECK-NEXT: vmax.vv v8, v8, v9
66 ; CHECK-NEXT: vsub.vv v8, v8, v10
68 %a.sext = sext <4 x i16> %a to <4 x i32>
69 %b.sext = sext <4 x i16> %b to <4 x i32>
70 %sub = sub <4 x i32> %a.sext, %b.sext
71 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
72 %trunc = trunc <4 x i32> %abs to <4 x i16>
76 define <4 x i16> @sabd_4h_promoted_ops(<4 x i8> %a, <4 x i8> %b) {
78 ; CHECK-LABEL: sabd_4h_promoted_ops:
80 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
81 ; CHECK-NEXT: vmin.vv v10, v8, v9
82 ; CHECK-NEXT: vmax.vv v8, v8, v9
83 ; CHECK-NEXT: vsub.vv v9, v8, v10
84 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
85 ; CHECK-NEXT: vzext.vf2 v8, v9
87 %a.sext = sext <4 x i8> %a to <4 x i16>
88 %b.sext = sext <4 x i8> %b to <4 x i16>
89 %sub = sub <4 x i16> %a.sext, %b.sext
90 %abs = call <4 x i16> @llvm.abs.v4i16(<4 x i16> %sub, i1 true)
94 define <8 x i16> @sabd_8h(<8 x i16> %a, <8 x i16> %b) {
96 ; CHECK-LABEL: sabd_8h:
98 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
99 ; CHECK-NEXT: vmin.vv v10, v8, v9
100 ; CHECK-NEXT: vmax.vv v8, v8, v9
101 ; CHECK-NEXT: vsub.vv v8, v8, v10
103 %a.sext = sext <8 x i16> %a to <8 x i32>
104 %b.sext = sext <8 x i16> %b to <8 x i32>
105 %sub = sub <8 x i32> %a.sext, %b.sext
106 %abs = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %sub, i1 true)
107 %trunc = trunc <8 x i32> %abs to <8 x i16>
111 define <8 x i16> @sabd_8h_promoted_ops(<8 x i8> %a, <8 x i8> %b) {
113 ; CHECK-LABEL: sabd_8h_promoted_ops:
115 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
116 ; CHECK-NEXT: vmin.vv v10, v8, v9
117 ; CHECK-NEXT: vmax.vv v8, v8, v9
118 ; CHECK-NEXT: vsub.vv v9, v8, v10
119 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
120 ; CHECK-NEXT: vzext.vf2 v8, v9
122 %a.sext = sext <8 x i8> %a to <8 x i16>
123 %b.sext = sext <8 x i8> %b to <8 x i16>
124 %sub = sub <8 x i16> %a.sext, %b.sext
125 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
129 define <2 x i32> @sabd_2s(<2 x i32> %a, <2 x i32> %b) {
131 ; CHECK-LABEL: sabd_2s:
133 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
134 ; CHECK-NEXT: vmin.vv v10, v8, v9
135 ; CHECK-NEXT: vmax.vv v8, v8, v9
136 ; CHECK-NEXT: vsub.vv v8, v8, v10
138 %a.sext = sext <2 x i32> %a to <2 x i64>
139 %b.sext = sext <2 x i32> %b to <2 x i64>
140 %sub = sub <2 x i64> %a.sext, %b.sext
141 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
142 %trunc = trunc <2 x i64> %abs to <2 x i32>
146 define <2 x i32> @sabd_2s_promoted_ops(<2 x i16> %a, <2 x i16> %b) {
148 ; CHECK-LABEL: sabd_2s_promoted_ops:
150 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
151 ; CHECK-NEXT: vmin.vv v10, v8, v9
152 ; CHECK-NEXT: vmax.vv v8, v8, v9
153 ; CHECK-NEXT: vsub.vv v9, v8, v10
154 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
155 ; CHECK-NEXT: vzext.vf2 v8, v9
157 %a.sext = sext <2 x i16> %a to <2 x i32>
158 %b.sext = sext <2 x i16> %b to <2 x i32>
159 %sub = sub <2 x i32> %a.sext, %b.sext
160 %abs = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %sub, i1 true)
164 define <4 x i32> @sabd_4s(<4 x i32> %a, <4 x i32> %b) {
166 ; CHECK-LABEL: sabd_4s:
168 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
169 ; CHECK-NEXT: vmin.vv v10, v8, v9
170 ; CHECK-NEXT: vmax.vv v8, v8, v9
171 ; CHECK-NEXT: vsub.vv v8, v8, v10
173 %a.sext = sext <4 x i32> %a to <4 x i64>
174 %b.sext = sext <4 x i32> %b to <4 x i64>
175 %sub = sub <4 x i64> %a.sext, %b.sext
176 %abs = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %sub, i1 true)
177 %trunc = trunc <4 x i64> %abs to <4 x i32>
181 define <4 x i32> @sabd_4s_promoted_ops(<4 x i16> %a, <4 x i16> %b) {
183 ; CHECK-LABEL: sabd_4s_promoted_ops:
185 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
186 ; CHECK-NEXT: vmin.vv v10, v8, v9
187 ; CHECK-NEXT: vmax.vv v8, v8, v9
188 ; CHECK-NEXT: vsub.vv v9, v8, v10
189 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
190 ; CHECK-NEXT: vzext.vf2 v8, v9
192 %a.sext = sext <4 x i16> %a to <4 x i32>
193 %b.sext = sext <4 x i16> %b to <4 x i32>
194 %sub = sub <4 x i32> %a.sext, %b.sext
195 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
199 define <2 x i64> @sabd_2d(<2 x i64> %a, <2 x i64> %b) {
200 ; CHECK-LABEL: sabd_2d:
202 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
203 ; CHECK-NEXT: vmin.vv v10, v8, v9
204 ; CHECK-NEXT: vmax.vv v8, v8, v9
205 ; CHECK-NEXT: vsub.vv v8, v8, v10
207 %a.sext = sext <2 x i64> %a to <2 x i128>
208 %b.sext = sext <2 x i64> %b to <2 x i128>
209 %sub = sub <2 x i128> %a.sext, %b.sext
210 %abs = call <2 x i128> @llvm.abs.v2i128(<2 x i128> %sub, i1 true)
211 %trunc = trunc <2 x i128> %abs to <2 x i64>
215 define <2 x i64> @sabd_2d_promoted_ops(<2 x i32> %a, <2 x i32> %b) {
217 ; CHECK-LABEL: sabd_2d_promoted_ops:
219 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
220 ; CHECK-NEXT: vmin.vv v10, v8, v9
221 ; CHECK-NEXT: vmax.vv v8, v8, v9
222 ; CHECK-NEXT: vsub.vv v9, v8, v10
223 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
224 ; CHECK-NEXT: vzext.vf2 v8, v9
226 %a.sext = sext <2 x i32> %a to <2 x i64>
227 %b.sext = sext <2 x i32> %b to <2 x i64>
228 %sub = sub <2 x i64> %a.sext, %b.sext
229 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
237 define <8 x i8> @uabd_8b(<8 x i8> %a, <8 x i8> %b) {
239 ; CHECK-LABEL: uabd_8b:
241 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
242 ; CHECK-NEXT: vminu.vv v10, v8, v9
243 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
244 ; CHECK-NEXT: vsub.vv v8, v8, v10
246 %a.zext = zext <8 x i8> %a to <8 x i16>
247 %b.zext = zext <8 x i8> %b to <8 x i16>
248 %sub = sub <8 x i16> %a.zext, %b.zext
249 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
250 %trunc = trunc <8 x i16> %abs to <8 x i8>
254 define <16 x i8> @uabd_16b(<16 x i8> %a, <16 x i8> %b) {
256 ; CHECK-LABEL: uabd_16b:
258 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
259 ; CHECK-NEXT: vminu.vv v10, v8, v9
260 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
261 ; CHECK-NEXT: vsub.vv v8, v8, v10
263 %a.zext = zext <16 x i8> %a to <16 x i16>
264 %b.zext = zext <16 x i8> %b to <16 x i16>
265 %sub = sub <16 x i16> %a.zext, %b.zext
266 %abs = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %sub, i1 true)
267 %trunc = trunc <16 x i16> %abs to <16 x i8>
271 define <4 x i16> @uabd_4h(<4 x i16> %a, <4 x i16> %b) {
273 ; CHECK-LABEL: uabd_4h:
275 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
276 ; CHECK-NEXT: vminu.vv v10, v8, v9
277 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
278 ; CHECK-NEXT: vsub.vv v8, v8, v10
280 %a.zext = zext <4 x i16> %a to <4 x i32>
281 %b.zext = zext <4 x i16> %b to <4 x i32>
282 %sub = sub <4 x i32> %a.zext, %b.zext
283 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
284 %trunc = trunc <4 x i32> %abs to <4 x i16>
288 define <4 x i16> @uabd_4h_promoted_ops(<4 x i8> %a, <4 x i8> %b) {
290 ; CHECK-LABEL: uabd_4h_promoted_ops:
292 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
293 ; CHECK-NEXT: vminu.vv v10, v8, v9
294 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
295 ; CHECK-NEXT: vsub.vv v9, v8, v10
296 ; CHECK-NEXT: vsetvli zero, zero, e16, mf2, ta, ma
297 ; CHECK-NEXT: vzext.vf2 v8, v9
299 %a.zext = zext <4 x i8> %a to <4 x i16>
300 %b.zext = zext <4 x i8> %b to <4 x i16>
301 %sub = sub <4 x i16> %a.zext, %b.zext
302 %abs = call <4 x i16> @llvm.abs.v4i16(<4 x i16> %sub, i1 true)
306 define <8 x i16> @uabd_8h(<8 x i16> %a, <8 x i16> %b) {
308 ; CHECK-LABEL: uabd_8h:
310 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
311 ; CHECK-NEXT: vminu.vv v10, v8, v9
312 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
313 ; CHECK-NEXT: vsub.vv v8, v8, v10
315 %a.zext = zext <8 x i16> %a to <8 x i32>
316 %b.zext = zext <8 x i16> %b to <8 x i32>
317 %sub = sub <8 x i32> %a.zext, %b.zext
318 %abs = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %sub, i1 true)
319 %trunc = trunc <8 x i32> %abs to <8 x i16>
323 define <8 x i16> @uabd_8h_promoted_ops(<8 x i8> %a, <8 x i8> %b) {
325 ; CHECK-LABEL: uabd_8h_promoted_ops:
327 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
328 ; CHECK-NEXT: vminu.vv v10, v8, v9
329 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
330 ; CHECK-NEXT: vsub.vv v9, v8, v10
331 ; CHECK-NEXT: vsetvli zero, zero, e16, m1, ta, ma
332 ; CHECK-NEXT: vzext.vf2 v8, v9
334 %a.zext = zext <8 x i8> %a to <8 x i16>
335 %b.zext = zext <8 x i8> %b to <8 x i16>
336 %sub = sub <8 x i16> %a.zext, %b.zext
337 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
341 define <2 x i32> @uabd_2s(<2 x i32> %a, <2 x i32> %b) {
343 ; CHECK-LABEL: uabd_2s:
345 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
346 ; CHECK-NEXT: vminu.vv v10, v8, v9
347 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
348 ; CHECK-NEXT: vsub.vv v8, v8, v10
350 %a.zext = zext <2 x i32> %a to <2 x i64>
351 %b.zext = zext <2 x i32> %b to <2 x i64>
352 %sub = sub <2 x i64> %a.zext, %b.zext
353 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
354 %trunc = trunc <2 x i64> %abs to <2 x i32>
358 define <2 x i32> @uabd_2s_promoted_ops(<2 x i16> %a, <2 x i16> %b) {
360 ; CHECK-LABEL: uabd_2s_promoted_ops:
362 ; CHECK-NEXT: vsetivli zero, 2, e16, mf4, ta, ma
363 ; CHECK-NEXT: vminu.vv v10, v8, v9
364 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
365 ; CHECK-NEXT: vsub.vv v9, v8, v10
366 ; CHECK-NEXT: vsetvli zero, zero, e32, mf2, ta, ma
367 ; CHECK-NEXT: vzext.vf2 v8, v9
369 %a.zext = zext <2 x i16> %a to <2 x i32>
370 %b.zext = zext <2 x i16> %b to <2 x i32>
371 %sub = sub <2 x i32> %a.zext, %b.zext
372 %abs = call <2 x i32> @llvm.abs.v2i32(<2 x i32> %sub, i1 true)
376 define <4 x i32> @uabd_4s(<4 x i32> %a, <4 x i32> %b) {
378 ; CHECK-LABEL: uabd_4s:
380 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
381 ; CHECK-NEXT: vminu.vv v10, v8, v9
382 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
383 ; CHECK-NEXT: vsub.vv v8, v8, v10
385 %a.zext = zext <4 x i32> %a to <4 x i64>
386 %b.zext = zext <4 x i32> %b to <4 x i64>
387 %sub = sub <4 x i64> %a.zext, %b.zext
388 %abs = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %sub, i1 true)
389 %trunc = trunc <4 x i64> %abs to <4 x i32>
393 define <4 x i32> @uabd_4s_promoted_ops(<4 x i16> %a, <4 x i16> %b) {
395 ; CHECK-LABEL: uabd_4s_promoted_ops:
397 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
398 ; CHECK-NEXT: vminu.vv v10, v8, v9
399 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
400 ; CHECK-NEXT: vsub.vv v9, v8, v10
401 ; CHECK-NEXT: vsetvli zero, zero, e32, m1, ta, ma
402 ; CHECK-NEXT: vzext.vf2 v8, v9
404 %a.zext = zext <4 x i16> %a to <4 x i32>
405 %b.zext = zext <4 x i16> %b to <4 x i32>
406 %sub = sub <4 x i32> %a.zext, %b.zext
407 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
411 define <2 x i64> @uabd_2d(<2 x i64> %a, <2 x i64> %b) {
412 ; CHECK-LABEL: uabd_2d:
414 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
415 ; CHECK-NEXT: vminu.vv v10, v8, v9
416 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
417 ; CHECK-NEXT: vsub.vv v8, v8, v10
419 %a.zext = zext <2 x i64> %a to <2 x i128>
420 %b.zext = zext <2 x i64> %b to <2 x i128>
421 %sub = sub <2 x i128> %a.zext, %b.zext
422 %abs = call <2 x i128> @llvm.abs.v2i128(<2 x i128> %sub, i1 true)
423 %trunc = trunc <2 x i128> %abs to <2 x i64>
427 define <2 x i64> @uabd_2d_promoted_ops(<2 x i32> %a, <2 x i32> %b) {
429 ; CHECK-LABEL: uabd_2d_promoted_ops:
431 ; CHECK-NEXT: vsetivli zero, 2, e32, mf2, ta, ma
432 ; CHECK-NEXT: vminu.vv v10, v8, v9
433 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
434 ; CHECK-NEXT: vsub.vv v9, v8, v10
435 ; CHECK-NEXT: vsetvli zero, zero, e64, m1, ta, ma
436 ; CHECK-NEXT: vzext.vf2 v8, v9
438 %a.zext = zext <2 x i32> %a to <2 x i64>
439 %b.zext = zext <2 x i32> %b to <2 x i64>
440 %sub = sub <2 x i64> %a.zext, %b.zext
441 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
445 define <16 x i8> @uabd_v16i8_nuw(<16 x i8> %a, <16 x i8> %b) {
447 ; CHECK-LABEL: uabd_v16i8_nuw:
449 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
450 ; CHECK-NEXT: vsub.vv v8, v8, v9
451 ; CHECK-NEXT: vrsub.vi v9, v8, 0
452 ; CHECK-NEXT: vmax.vv v8, v8, v9
454 %sub = sub nuw <16 x i8> %a, %b
455 %abs = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %sub, i1 true)
459 define <8 x i16> @uabd_v8i16_nuw(<8 x i16> %a, <8 x i16> %b) {
461 ; CHECK-LABEL: uabd_v8i16_nuw:
463 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
464 ; CHECK-NEXT: vsub.vv v8, v8, v9
465 ; CHECK-NEXT: vrsub.vi v9, v8, 0
466 ; CHECK-NEXT: vmax.vv v8, v8, v9
468 %sub = sub nuw <8 x i16> %a, %b
469 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
473 define <4 x i32> @uabd_v4i32_nuw(<4 x i32> %a, <4 x i32> %b) {
475 ; CHECK-LABEL: uabd_v4i32_nuw:
477 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
478 ; CHECK-NEXT: vsub.vv v8, v8, v9
479 ; CHECK-NEXT: vrsub.vi v9, v8, 0
480 ; CHECK-NEXT: vmax.vv v8, v8, v9
482 %sub = sub nuw <4 x i32> %a, %b
483 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
487 define <2 x i64> @uabd_v2i64_nuw(<2 x i64> %a, <2 x i64> %b) {
489 ; CHECK-LABEL: uabd_v2i64_nuw:
491 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
492 ; CHECK-NEXT: vsub.vv v8, v8, v9
493 ; CHECK-NEXT: vrsub.vi v9, v8, 0
494 ; CHECK-NEXT: vmax.vv v8, v8, v9
496 %sub = sub nuw <2 x i64> %a, %b
497 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
501 define <16 x i8> @sabd_v16i8_nsw(<16 x i8> %a, <16 x i8> %b) {
503 ; CHECK-LABEL: sabd_v16i8_nsw:
505 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
506 ; CHECK-NEXT: vmin.vv v10, v8, v9
507 ; CHECK-NEXT: vmax.vv v8, v8, v9
508 ; CHECK-NEXT: vsub.vv v8, v8, v10
510 %sub = sub nsw <16 x i8> %a, %b
511 %abs = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %sub, i1 true)
515 define <8 x i16> @sabd_v8i16_nsw(<8 x i16> %a, <8 x i16> %b) {
517 ; CHECK-LABEL: sabd_v8i16_nsw:
519 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
520 ; CHECK-NEXT: vmin.vv v10, v8, v9
521 ; CHECK-NEXT: vmax.vv v8, v8, v9
522 ; CHECK-NEXT: vsub.vv v8, v8, v10
524 %sub = sub nsw <8 x i16> %a, %b
525 %abs = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %sub, i1 true)
529 define <4 x i32> @sabd_v4i32_nsw(<4 x i32> %a, <4 x i32> %b) {
531 ; CHECK-LABEL: sabd_v4i32_nsw:
533 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
534 ; CHECK-NEXT: vmin.vv v10, v8, v9
535 ; CHECK-NEXT: vmax.vv v8, v8, v9
536 ; CHECK-NEXT: vsub.vv v8, v8, v10
538 %sub = sub nsw <4 x i32> %a, %b
539 %abs = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %sub, i1 true)
543 define <2 x i64> @sabd_v2i64_nsw(<2 x i64> %a, <2 x i64> %b) {
545 ; CHECK-LABEL: sabd_v2i64_nsw:
547 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
548 ; CHECK-NEXT: vmin.vv v10, v8, v9
549 ; CHECK-NEXT: vmax.vv v8, v8, v9
550 ; CHECK-NEXT: vsub.vv v8, v8, v10
552 %sub = sub nsw <2 x i64> %a, %b
553 %abs = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %sub, i1 true)
557 define <16 x i8> @smaxmin_v16i8(<16 x i8> %0, <16 x i8> %1) {
559 ; CHECK-LABEL: smaxmin_v16i8:
561 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
562 ; CHECK-NEXT: vmin.vv v10, v8, v9
563 ; CHECK-NEXT: vmax.vv v8, v8, v9
564 ; CHECK-NEXT: vsub.vv v8, v8, v10
566 %a = tail call <16 x i8> @llvm.smax.v16i8(<16 x i8> %0, <16 x i8> %1)
567 %b = tail call <16 x i8> @llvm.smin.v16i8(<16 x i8> %0, <16 x i8> %1)
568 %sub = sub <16 x i8> %a, %b
572 define <8 x i16> @smaxmin_v8i16(<8 x i16> %0, <8 x i16> %1) {
574 ; CHECK-LABEL: smaxmin_v8i16:
576 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
577 ; CHECK-NEXT: vmin.vv v10, v8, v9
578 ; CHECK-NEXT: vmax.vv v8, v8, v9
579 ; CHECK-NEXT: vsub.vv v8, v8, v10
581 %a = tail call <8 x i16> @llvm.smax.v8i16(<8 x i16> %0, <8 x i16> %1)
582 %b = tail call <8 x i16> @llvm.smin.v8i16(<8 x i16> %0, <8 x i16> %1)
583 %sub = sub <8 x i16> %a, %b
587 define <4 x i32> @smaxmin_v4i32(<4 x i32> %0, <4 x i32> %1) {
589 ; CHECK-LABEL: smaxmin_v4i32:
591 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
592 ; CHECK-NEXT: vmin.vv v10, v8, v9
593 ; CHECK-NEXT: vmax.vv v8, v8, v9
594 ; CHECK-NEXT: vsub.vv v8, v8, v10
596 %a = tail call <4 x i32> @llvm.smax.v4i32(<4 x i32> %0, <4 x i32> %1)
597 %b = tail call <4 x i32> @llvm.smin.v4i32(<4 x i32> %0, <4 x i32> %1)
598 %sub = sub <4 x i32> %a, %b
602 define <2 x i64> @smaxmin_v2i64(<2 x i64> %0, <2 x i64> %1) {
604 ; CHECK-LABEL: smaxmin_v2i64:
606 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
607 ; CHECK-NEXT: vmin.vv v10, v8, v9
608 ; CHECK-NEXT: vmax.vv v8, v8, v9
609 ; CHECK-NEXT: vsub.vv v8, v8, v10
611 %a = tail call <2 x i64> @llvm.smax.v2i64(<2 x i64> %0, <2 x i64> %1)
612 %b = tail call <2 x i64> @llvm.smin.v2i64(<2 x i64> %0, <2 x i64> %1)
613 %sub = sub <2 x i64> %a, %b
617 define <16 x i8> @umaxmin_v16i8(<16 x i8> %0, <16 x i8> %1) {
619 ; CHECK-LABEL: umaxmin_v16i8:
621 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
622 ; CHECK-NEXT: vminu.vv v10, v8, v9
623 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
624 ; CHECK-NEXT: vsub.vv v8, v8, v10
626 %a = tail call <16 x i8> @llvm.umax.v16i8(<16 x i8> %0, <16 x i8> %1)
627 %b = tail call <16 x i8> @llvm.umin.v16i8(<16 x i8> %0, <16 x i8> %1)
628 %sub = sub <16 x i8> %a, %b
632 define <8 x i16> @umaxmin_v8i16(<8 x i16> %0, <8 x i16> %1) {
634 ; CHECK-LABEL: umaxmin_v8i16:
636 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
637 ; CHECK-NEXT: vminu.vv v10, v8, v9
638 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
639 ; CHECK-NEXT: vsub.vv v8, v8, v10
641 %a = tail call <8 x i16> @llvm.umax.v8i16(<8 x i16> %0, <8 x i16> %1)
642 %b = tail call <8 x i16> @llvm.umin.v8i16(<8 x i16> %0, <8 x i16> %1)
643 %sub = sub <8 x i16> %a, %b
647 define <4 x i32> @umaxmin_v4i32(<4 x i32> %0, <4 x i32> %1) {
649 ; CHECK-LABEL: umaxmin_v4i32:
651 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
652 ; CHECK-NEXT: vminu.vv v10, v8, v9
653 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
654 ; CHECK-NEXT: vsub.vv v8, v8, v10
656 %a = tail call <4 x i32> @llvm.umax.v4i32(<4 x i32> %0, <4 x i32> %1)
657 %b = tail call <4 x i32> @llvm.umin.v4i32(<4 x i32> %0, <4 x i32> %1)
658 %sub = sub <4 x i32> %a, %b
662 define <2 x i64> @umaxmin_v2i64(<2 x i64> %0, <2 x i64> %1) {
664 ; CHECK-LABEL: umaxmin_v2i64:
666 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
667 ; CHECK-NEXT: vminu.vv v10, v8, v9
668 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
669 ; CHECK-NEXT: vsub.vv v8, v8, v10
671 %a = tail call <2 x i64> @llvm.umax.v2i64(<2 x i64> %0, <2 x i64> %1)
672 %b = tail call <2 x i64> @llvm.umin.v2i64(<2 x i64> %0, <2 x i64> %1)
673 %sub = sub <2 x i64> %a, %b
677 define <16 x i8> @umaxmin_v16i8_com1(<16 x i8> %0, <16 x i8> %1) {
679 ; CHECK-LABEL: umaxmin_v16i8_com1:
681 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
682 ; CHECK-NEXT: vminu.vv v10, v8, v9
683 ; CHECK-NEXT: vmaxu.vv v8, v8, v9
684 ; CHECK-NEXT: vsub.vv v8, v8, v10
686 %a = tail call <16 x i8> @llvm.umax.v16i8(<16 x i8> %0, <16 x i8> %1)
687 %b = tail call <16 x i8> @llvm.umin.v16i8(<16 x i8> %1, <16 x i8> %0)
688 %sub = sub <16 x i8> %a, %b
692 declare <8 x i8> @llvm.abs.v8i8(<8 x i8>, i1)
693 declare <16 x i8> @llvm.abs.v16i8(<16 x i8>, i1)
695 declare <4 x i16> @llvm.abs.v4i16(<4 x i16>, i1)
696 declare <8 x i16> @llvm.abs.v8i16(<8 x i16>, i1)
697 declare <16 x i16> @llvm.abs.v16i16(<16 x i16>, i1)
699 declare <2 x i32> @llvm.abs.v2i32(<2 x i32>, i1)
700 declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
701 declare <8 x i32> @llvm.abs.v8i32(<8 x i32>, i1)
703 declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1)
704 declare <4 x i64> @llvm.abs.v4i64(<4 x i64>, i1)
706 declare <2 x i128> @llvm.abs.v2i128(<2 x i128>, i1)
708 declare <16 x i8> @llvm.smax.v16i8(<16 x i8>, <16 x i8>)
709 declare <8 x i16> @llvm.smax.v8i16(<8 x i16>, <8 x i16>)
710 declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>)
711 declare <2 x i64> @llvm.smax.v2i64(<2 x i64>, <2 x i64>)
712 declare <16 x i8> @llvm.smin.v16i8(<16 x i8>, <16 x i8>)
713 declare <8 x i16> @llvm.smin.v8i16(<8 x i16>, <8 x i16>)
714 declare <4 x i32> @llvm.smin.v4i32(<4 x i32>, <4 x i32>)
715 declare <2 x i64> @llvm.smin.v2i64(<2 x i64>, <2 x i64>)
716 declare <16 x i8> @llvm.umax.v16i8(<16 x i8>, <16 x i8>)
717 declare <8 x i16> @llvm.umax.v8i16(<8 x i16>, <8 x i16>)
718 declare <4 x i32> @llvm.umax.v4i32(<4 x i32>, <4 x i32>)
719 declare <2 x i64> @llvm.umax.v2i64(<2 x i64>, <2 x i64>)
720 declare <16 x i8> @llvm.umin.v16i8(<16 x i8>, <16 x i8>)
721 declare <8 x i16> @llvm.umin.v8i16(<8 x i16>, <8 x i16>)
722 declare <4 x i32> @llvm.umin.v4i32(<4 x i32>, <4 x i32>)
723 declare <2 x i64> @llvm.umin.v2i64(<2 x i64>, <2 x i64>)
725 ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: