1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
3 ; RUN: | FileCheck %s --check-prefix=RV32I
4 ; RUN: llc -mtriple=riscv32 -mattr=+zbb -verify-machineinstrs < %s \
5 ; RUN: | FileCheck %s --check-prefix=RV32ZBB
6 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
7 ; RUN: | FileCheck %s --check-prefix=RV64I
8 ; RUN: llc -mtriple=riscv64 -mattr=+zbb -verify-machineinstrs < %s \
9 ; RUN: | FileCheck %s --check-prefix=RV64ZBB
11 declare i8 @llvm.abs.i8(i8, i1 immarg)
12 declare i16 @llvm.abs.i16(i16, i1 immarg)
13 declare i32 @llvm.abs.i32(i32, i1 immarg)
14 declare i64 @llvm.abs.i64(i64, i1 immarg)
15 declare i128 @llvm.abs.i128(i128, i1 immarg)
17 define i8 @abs8(i8 %x) {
20 ; RV32I-NEXT: slli a1, a0, 24
21 ; RV32I-NEXT: srai a1, a1, 31
22 ; RV32I-NEXT: xor a0, a0, a1
23 ; RV32I-NEXT: sub a0, a0, a1
26 ; RV32ZBB-LABEL: abs8:
28 ; RV32ZBB-NEXT: sext.b a0, a0
29 ; RV32ZBB-NEXT: neg a1, a0
30 ; RV32ZBB-NEXT: max a0, a0, a1
35 ; RV64I-NEXT: slli a1, a0, 56
36 ; RV64I-NEXT: srai a1, a1, 63
37 ; RV64I-NEXT: xor a0, a0, a1
38 ; RV64I-NEXT: sub a0, a0, a1
41 ; RV64ZBB-LABEL: abs8:
43 ; RV64ZBB-NEXT: sext.b a0, a0
44 ; RV64ZBB-NEXT: neg a1, a0
45 ; RV64ZBB-NEXT: max a0, a0, a1
47 %abs = tail call i8 @llvm.abs.i8(i8 %x, i1 true)
51 define i8 @select_abs8(i8 %x) {
52 ; RV32I-LABEL: select_abs8:
54 ; RV32I-NEXT: slli a1, a0, 24
55 ; RV32I-NEXT: srai a1, a1, 31
56 ; RV32I-NEXT: xor a0, a0, a1
57 ; RV32I-NEXT: sub a0, a0, a1
60 ; RV32ZBB-LABEL: select_abs8:
62 ; RV32ZBB-NEXT: sext.b a0, a0
63 ; RV32ZBB-NEXT: neg a1, a0
64 ; RV32ZBB-NEXT: max a0, a0, a1
67 ; RV64I-LABEL: select_abs8:
69 ; RV64I-NEXT: slli a1, a0, 56
70 ; RV64I-NEXT: srai a1, a1, 63
71 ; RV64I-NEXT: xor a0, a0, a1
72 ; RV64I-NEXT: sub a0, a0, a1
75 ; RV64ZBB-LABEL: select_abs8:
77 ; RV64ZBB-NEXT: sext.b a0, a0
78 ; RV64ZBB-NEXT: neg a1, a0
79 ; RV64ZBB-NEXT: max a0, a0, a1
81 %1 = icmp slt i8 %x, 0
83 %3 = select i1 %1, i8 %2, i8 %x
87 define i16 @abs16(i16 %x) {
90 ; RV32I-NEXT: slli a1, a0, 16
91 ; RV32I-NEXT: srai a1, a1, 31
92 ; RV32I-NEXT: xor a0, a0, a1
93 ; RV32I-NEXT: sub a0, a0, a1
96 ; RV32ZBB-LABEL: abs16:
98 ; RV32ZBB-NEXT: sext.h a0, a0
99 ; RV32ZBB-NEXT: neg a1, a0
100 ; RV32ZBB-NEXT: max a0, a0, a1
103 ; RV64I-LABEL: abs16:
105 ; RV64I-NEXT: slli a1, a0, 48
106 ; RV64I-NEXT: srai a1, a1, 63
107 ; RV64I-NEXT: xor a0, a0, a1
108 ; RV64I-NEXT: sub a0, a0, a1
111 ; RV64ZBB-LABEL: abs16:
113 ; RV64ZBB-NEXT: sext.h a0, a0
114 ; RV64ZBB-NEXT: neg a1, a0
115 ; RV64ZBB-NEXT: max a0, a0, a1
117 %abs = tail call i16 @llvm.abs.i16(i16 %x, i1 true)
121 define i16 @select_abs16(i16 %x) {
122 ; RV32I-LABEL: select_abs16:
124 ; RV32I-NEXT: slli a1, a0, 16
125 ; RV32I-NEXT: srai a1, a1, 31
126 ; RV32I-NEXT: xor a0, a0, a1
127 ; RV32I-NEXT: sub a0, a0, a1
130 ; RV32ZBB-LABEL: select_abs16:
132 ; RV32ZBB-NEXT: sext.h a0, a0
133 ; RV32ZBB-NEXT: neg a1, a0
134 ; RV32ZBB-NEXT: max a0, a0, a1
137 ; RV64I-LABEL: select_abs16:
139 ; RV64I-NEXT: slli a1, a0, 48
140 ; RV64I-NEXT: srai a1, a1, 63
141 ; RV64I-NEXT: xor a0, a0, a1
142 ; RV64I-NEXT: sub a0, a0, a1
145 ; RV64ZBB-LABEL: select_abs16:
147 ; RV64ZBB-NEXT: sext.h a0, a0
148 ; RV64ZBB-NEXT: neg a1, a0
149 ; RV64ZBB-NEXT: max a0, a0, a1
151 %1 = icmp slt i16 %x, 0
152 %2 = sub nsw i16 0, %x
153 %3 = select i1 %1, i16 %2, i16 %x
157 define i32 @abs32(i32 %x) {
158 ; RV32I-LABEL: abs32:
160 ; RV32I-NEXT: srai a1, a0, 31
161 ; RV32I-NEXT: xor a0, a0, a1
162 ; RV32I-NEXT: sub a0, a0, a1
165 ; RV32ZBB-LABEL: abs32:
167 ; RV32ZBB-NEXT: neg a1, a0
168 ; RV32ZBB-NEXT: max a0, a0, a1
171 ; RV64I-LABEL: abs32:
173 ; RV64I-NEXT: sraiw a1, a0, 31
174 ; RV64I-NEXT: xor a0, a0, a1
175 ; RV64I-NEXT: subw a0, a0, a1
178 ; RV64ZBB-LABEL: abs32:
180 ; RV64ZBB-NEXT: sext.w a0, a0
181 ; RV64ZBB-NEXT: negw a1, a0
182 ; RV64ZBB-NEXT: max a0, a0, a1
184 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
188 define i32 @select_abs32(i32 %x) {
189 ; RV32I-LABEL: select_abs32:
191 ; RV32I-NEXT: srai a1, a0, 31
192 ; RV32I-NEXT: xor a0, a0, a1
193 ; RV32I-NEXT: sub a0, a0, a1
196 ; RV32ZBB-LABEL: select_abs32:
198 ; RV32ZBB-NEXT: neg a1, a0
199 ; RV32ZBB-NEXT: max a0, a0, a1
202 ; RV64I-LABEL: select_abs32:
204 ; RV64I-NEXT: sraiw a1, a0, 31
205 ; RV64I-NEXT: xor a0, a0, a1
206 ; RV64I-NEXT: subw a0, a0, a1
209 ; RV64ZBB-LABEL: select_abs32:
211 ; RV64ZBB-NEXT: sext.w a0, a0
212 ; RV64ZBB-NEXT: negw a1, a0
213 ; RV64ZBB-NEXT: max a0, a0, a1
215 %1 = icmp slt i32 %x, 0
216 %2 = sub nsw i32 0, %x
217 %3 = select i1 %1, i32 %2, i32 %x
221 define i64 @abs64(i64 %x) {
222 ; RV32I-LABEL: abs64:
224 ; RV32I-NEXT: bgez a1, .LBB6_2
225 ; RV32I-NEXT: # %bb.1:
226 ; RV32I-NEXT: snez a2, a0
227 ; RV32I-NEXT: neg a0, a0
228 ; RV32I-NEXT: neg a1, a1
229 ; RV32I-NEXT: sub a1, a1, a2
230 ; RV32I-NEXT: .LBB6_2:
233 ; RV32ZBB-LABEL: abs64:
235 ; RV32ZBB-NEXT: bgez a1, .LBB6_2
236 ; RV32ZBB-NEXT: # %bb.1:
237 ; RV32ZBB-NEXT: snez a2, a0
238 ; RV32ZBB-NEXT: neg a0, a0
239 ; RV32ZBB-NEXT: neg a1, a1
240 ; RV32ZBB-NEXT: sub a1, a1, a2
241 ; RV32ZBB-NEXT: .LBB6_2:
244 ; RV64I-LABEL: abs64:
246 ; RV64I-NEXT: srai a1, a0, 63
247 ; RV64I-NEXT: xor a0, a0, a1
248 ; RV64I-NEXT: sub a0, a0, a1
251 ; RV64ZBB-LABEL: abs64:
253 ; RV64ZBB-NEXT: neg a1, a0
254 ; RV64ZBB-NEXT: max a0, a0, a1
256 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
260 define i64 @select_abs64(i64 %x) {
261 ; RV32I-LABEL: select_abs64:
263 ; RV32I-NEXT: bgez a1, .LBB7_2
264 ; RV32I-NEXT: # %bb.1:
265 ; RV32I-NEXT: snez a2, a0
266 ; RV32I-NEXT: neg a0, a0
267 ; RV32I-NEXT: neg a1, a1
268 ; RV32I-NEXT: sub a1, a1, a2
269 ; RV32I-NEXT: .LBB7_2:
272 ; RV32ZBB-LABEL: select_abs64:
274 ; RV32ZBB-NEXT: bgez a1, .LBB7_2
275 ; RV32ZBB-NEXT: # %bb.1:
276 ; RV32ZBB-NEXT: snez a2, a0
277 ; RV32ZBB-NEXT: neg a0, a0
278 ; RV32ZBB-NEXT: neg a1, a1
279 ; RV32ZBB-NEXT: sub a1, a1, a2
280 ; RV32ZBB-NEXT: .LBB7_2:
283 ; RV64I-LABEL: select_abs64:
285 ; RV64I-NEXT: srai a1, a0, 63
286 ; RV64I-NEXT: xor a0, a0, a1
287 ; RV64I-NEXT: sub a0, a0, a1
290 ; RV64ZBB-LABEL: select_abs64:
292 ; RV64ZBB-NEXT: neg a1, a0
293 ; RV64ZBB-NEXT: max a0, a0, a1
295 %1 = icmp slt i64 %x, 0
296 %2 = sub nsw i64 0, %x
297 %3 = select i1 %1, i64 %2, i64 %x
301 define i128 @abs128(i128 %x) {
302 ; RV32I-LABEL: abs128:
304 ; RV32I-NEXT: lw a2, 12(a1)
305 ; RV32I-NEXT: lw a3, 4(a1)
306 ; RV32I-NEXT: lw a4, 0(a1)
307 ; RV32I-NEXT: lw a1, 8(a1)
308 ; RV32I-NEXT: bgez a2, .LBB8_2
309 ; RV32I-NEXT: # %bb.1:
310 ; RV32I-NEXT: neg a5, a1
311 ; RV32I-NEXT: or a6, a4, a3
312 ; RV32I-NEXT: snez a6, a6
313 ; RV32I-NEXT: sltu a7, a5, a6
314 ; RV32I-NEXT: snez a1, a1
315 ; RV32I-NEXT: add a1, a2, a1
316 ; RV32I-NEXT: neg a1, a1
317 ; RV32I-NEXT: sub a2, a1, a7
318 ; RV32I-NEXT: sub a1, a5, a6
319 ; RV32I-NEXT: snez a5, a4
320 ; RV32I-NEXT: neg a3, a3
321 ; RV32I-NEXT: sub a3, a3, a5
322 ; RV32I-NEXT: neg a4, a4
323 ; RV32I-NEXT: .LBB8_2:
324 ; RV32I-NEXT: sw a4, 0(a0)
325 ; RV32I-NEXT: sw a1, 8(a0)
326 ; RV32I-NEXT: sw a3, 4(a0)
327 ; RV32I-NEXT: sw a2, 12(a0)
330 ; RV32ZBB-LABEL: abs128:
332 ; RV32ZBB-NEXT: lw a2, 12(a1)
333 ; RV32ZBB-NEXT: lw a3, 4(a1)
334 ; RV32ZBB-NEXT: lw a4, 0(a1)
335 ; RV32ZBB-NEXT: lw a1, 8(a1)
336 ; RV32ZBB-NEXT: bgez a2, .LBB8_2
337 ; RV32ZBB-NEXT: # %bb.1:
338 ; RV32ZBB-NEXT: neg a5, a1
339 ; RV32ZBB-NEXT: or a6, a4, a3
340 ; RV32ZBB-NEXT: snez a6, a6
341 ; RV32ZBB-NEXT: sltu a7, a5, a6
342 ; RV32ZBB-NEXT: snez a1, a1
343 ; RV32ZBB-NEXT: add a1, a2, a1
344 ; RV32ZBB-NEXT: neg a1, a1
345 ; RV32ZBB-NEXT: sub a2, a1, a7
346 ; RV32ZBB-NEXT: sub a1, a5, a6
347 ; RV32ZBB-NEXT: snez a5, a4
348 ; RV32ZBB-NEXT: neg a3, a3
349 ; RV32ZBB-NEXT: sub a3, a3, a5
350 ; RV32ZBB-NEXT: neg a4, a4
351 ; RV32ZBB-NEXT: .LBB8_2:
352 ; RV32ZBB-NEXT: sw a4, 0(a0)
353 ; RV32ZBB-NEXT: sw a1, 8(a0)
354 ; RV32ZBB-NEXT: sw a3, 4(a0)
355 ; RV32ZBB-NEXT: sw a2, 12(a0)
358 ; RV64I-LABEL: abs128:
360 ; RV64I-NEXT: bgez a1, .LBB8_2
361 ; RV64I-NEXT: # %bb.1:
362 ; RV64I-NEXT: snez a2, a0
363 ; RV64I-NEXT: neg a0, a0
364 ; RV64I-NEXT: neg a1, a1
365 ; RV64I-NEXT: sub a1, a1, a2
366 ; RV64I-NEXT: .LBB8_2:
369 ; RV64ZBB-LABEL: abs128:
371 ; RV64ZBB-NEXT: bgez a1, .LBB8_2
372 ; RV64ZBB-NEXT: # %bb.1:
373 ; RV64ZBB-NEXT: snez a2, a0
374 ; RV64ZBB-NEXT: neg a0, a0
375 ; RV64ZBB-NEXT: neg a1, a1
376 ; RV64ZBB-NEXT: sub a1, a1, a2
377 ; RV64ZBB-NEXT: .LBB8_2:
379 %abs = tail call i128 @llvm.abs.i128(i128 %x, i1 true)
383 define i128 @select_abs128(i128 %x) {
384 ; RV32I-LABEL: select_abs128:
386 ; RV32I-NEXT: lw a2, 12(a1)
387 ; RV32I-NEXT: lw a3, 4(a1)
388 ; RV32I-NEXT: lw a4, 0(a1)
389 ; RV32I-NEXT: lw a1, 8(a1)
390 ; RV32I-NEXT: bgez a2, .LBB9_2
391 ; RV32I-NEXT: # %bb.1:
392 ; RV32I-NEXT: neg a5, a1
393 ; RV32I-NEXT: or a6, a4, a3
394 ; RV32I-NEXT: snez a6, a6
395 ; RV32I-NEXT: sltu a7, a5, a6
396 ; RV32I-NEXT: snez a1, a1
397 ; RV32I-NEXT: add a1, a2, a1
398 ; RV32I-NEXT: neg a1, a1
399 ; RV32I-NEXT: sub a2, a1, a7
400 ; RV32I-NEXT: sub a1, a5, a6
401 ; RV32I-NEXT: snez a5, a4
402 ; RV32I-NEXT: neg a3, a3
403 ; RV32I-NEXT: sub a3, a3, a5
404 ; RV32I-NEXT: neg a4, a4
405 ; RV32I-NEXT: .LBB9_2:
406 ; RV32I-NEXT: sw a4, 0(a0)
407 ; RV32I-NEXT: sw a1, 8(a0)
408 ; RV32I-NEXT: sw a3, 4(a0)
409 ; RV32I-NEXT: sw a2, 12(a0)
412 ; RV32ZBB-LABEL: select_abs128:
414 ; RV32ZBB-NEXT: lw a2, 12(a1)
415 ; RV32ZBB-NEXT: lw a3, 4(a1)
416 ; RV32ZBB-NEXT: lw a4, 0(a1)
417 ; RV32ZBB-NEXT: lw a1, 8(a1)
418 ; RV32ZBB-NEXT: bgez a2, .LBB9_2
419 ; RV32ZBB-NEXT: # %bb.1:
420 ; RV32ZBB-NEXT: neg a5, a1
421 ; RV32ZBB-NEXT: or a6, a4, a3
422 ; RV32ZBB-NEXT: snez a6, a6
423 ; RV32ZBB-NEXT: sltu a7, a5, a6
424 ; RV32ZBB-NEXT: snez a1, a1
425 ; RV32ZBB-NEXT: add a1, a2, a1
426 ; RV32ZBB-NEXT: neg a1, a1
427 ; RV32ZBB-NEXT: sub a2, a1, a7
428 ; RV32ZBB-NEXT: sub a1, a5, a6
429 ; RV32ZBB-NEXT: snez a5, a4
430 ; RV32ZBB-NEXT: neg a3, a3
431 ; RV32ZBB-NEXT: sub a3, a3, a5
432 ; RV32ZBB-NEXT: neg a4, a4
433 ; RV32ZBB-NEXT: .LBB9_2:
434 ; RV32ZBB-NEXT: sw a4, 0(a0)
435 ; RV32ZBB-NEXT: sw a1, 8(a0)
436 ; RV32ZBB-NEXT: sw a3, 4(a0)
437 ; RV32ZBB-NEXT: sw a2, 12(a0)
440 ; RV64I-LABEL: select_abs128:
442 ; RV64I-NEXT: bgez a1, .LBB9_2
443 ; RV64I-NEXT: # %bb.1:
444 ; RV64I-NEXT: snez a2, a0
445 ; RV64I-NEXT: neg a0, a0
446 ; RV64I-NEXT: neg a1, a1
447 ; RV64I-NEXT: sub a1, a1, a2
448 ; RV64I-NEXT: .LBB9_2:
451 ; RV64ZBB-LABEL: select_abs128:
453 ; RV64ZBB-NEXT: bgez a1, .LBB9_2
454 ; RV64ZBB-NEXT: # %bb.1:
455 ; RV64ZBB-NEXT: snez a2, a0
456 ; RV64ZBB-NEXT: neg a0, a0
457 ; RV64ZBB-NEXT: neg a1, a1
458 ; RV64ZBB-NEXT: sub a1, a1, a2
459 ; RV64ZBB-NEXT: .LBB9_2:
461 %1 = icmp slt i128 %x, 0
462 %2 = sub nsw i128 0, %x
463 %3 = select i1 %1, i128 %2, i128 %x
467 define i64 @zext_abs32(i32 %x) {
468 ; RV32I-LABEL: zext_abs32:
470 ; RV32I-NEXT: srai a1, a0, 31
471 ; RV32I-NEXT: xor a0, a0, a1
472 ; RV32I-NEXT: sub a0, a0, a1
473 ; RV32I-NEXT: li a1, 0
476 ; RV32ZBB-LABEL: zext_abs32:
478 ; RV32ZBB-NEXT: neg a1, a0
479 ; RV32ZBB-NEXT: max a0, a0, a1
480 ; RV32ZBB-NEXT: li a1, 0
483 ; RV64I-LABEL: zext_abs32:
485 ; RV64I-NEXT: sraiw a1, a0, 31
486 ; RV64I-NEXT: xor a0, a0, a1
487 ; RV64I-NEXT: subw a0, a0, a1
490 ; RV64ZBB-LABEL: zext_abs32:
492 ; RV64ZBB-NEXT: sext.w a0, a0
493 ; RV64ZBB-NEXT: negw a1, a0
494 ; RV64ZBB-NEXT: max a0, a0, a1
496 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
497 %zext = zext nneg i32 %abs to i64
501 define signext i32 @zext_abs8(i8 signext %x) {
502 ; RV32I-LABEL: zext_abs8:
504 ; RV32I-NEXT: srai a1, a0, 31
505 ; RV32I-NEXT: xor a0, a0, a1
506 ; RV32I-NEXT: sub a0, a0, a1
509 ; RV32ZBB-LABEL: zext_abs8:
511 ; RV32ZBB-NEXT: neg a1, a0
512 ; RV32ZBB-NEXT: max a0, a0, a1
515 ; RV64I-LABEL: zext_abs8:
517 ; RV64I-NEXT: srai a1, a0, 63
518 ; RV64I-NEXT: xor a0, a0, a1
519 ; RV64I-NEXT: sub a0, a0, a1
522 ; RV64ZBB-LABEL: zext_abs8:
524 ; RV64ZBB-NEXT: neg a1, a0
525 ; RV64ZBB-NEXT: max a0, a0, a1
527 %a = call i8 @llvm.abs.i8(i8 %x, i1 false)
528 %b = zext i8 %a to i32
532 define signext i32 @zext_abs16(i16 signext %x) {
533 ; RV32I-LABEL: zext_abs16:
535 ; RV32I-NEXT: srai a1, a0, 31
536 ; RV32I-NEXT: xor a0, a0, a1
537 ; RV32I-NEXT: sub a0, a0, a1
540 ; RV32ZBB-LABEL: zext_abs16:
542 ; RV32ZBB-NEXT: neg a1, a0
543 ; RV32ZBB-NEXT: max a0, a0, a1
546 ; RV64I-LABEL: zext_abs16:
548 ; RV64I-NEXT: srai a1, a0, 63
549 ; RV64I-NEXT: xor a0, a0, a1
550 ; RV64I-NEXT: sub a0, a0, a1
553 ; RV64ZBB-LABEL: zext_abs16:
555 ; RV64ZBB-NEXT: neg a1, a0
556 ; RV64ZBB-NEXT: max a0, a0, a1
558 %a = call i16 @llvm.abs.i16(i16 %x, i1 false)
559 %b = zext i16 %a to i32
563 define i64 @zext64_abs8(i8 signext %x) {
564 ; RV32I-LABEL: zext64_abs8:
566 ; RV32I-NEXT: srai a1, a0, 31
567 ; RV32I-NEXT: xor a0, a0, a1
568 ; RV32I-NEXT: sub a0, a0, a1
569 ; RV32I-NEXT: li a1, 0
572 ; RV32ZBB-LABEL: zext64_abs8:
574 ; RV32ZBB-NEXT: neg a1, a0
575 ; RV32ZBB-NEXT: max a0, a0, a1
576 ; RV32ZBB-NEXT: li a1, 0
579 ; RV64I-LABEL: zext64_abs8:
581 ; RV64I-NEXT: srai a1, a0, 63
582 ; RV64I-NEXT: xor a0, a0, a1
583 ; RV64I-NEXT: sub a0, a0, a1
586 ; RV64ZBB-LABEL: zext64_abs8:
588 ; RV64ZBB-NEXT: neg a1, a0
589 ; RV64ZBB-NEXT: max a0, a0, a1
591 %a = call i8 @llvm.abs.i8(i8 %x, i1 false)
592 %b = zext i8 %a to i64
596 define i64 @zext64_abs16(i16 signext %x) {
597 ; RV32I-LABEL: zext64_abs16:
599 ; RV32I-NEXT: srai a1, a0, 31
600 ; RV32I-NEXT: xor a0, a0, a1
601 ; RV32I-NEXT: sub a0, a0, a1
602 ; RV32I-NEXT: li a1, 0
605 ; RV32ZBB-LABEL: zext64_abs16:
607 ; RV32ZBB-NEXT: neg a1, a0
608 ; RV32ZBB-NEXT: max a0, a0, a1
609 ; RV32ZBB-NEXT: li a1, 0
612 ; RV64I-LABEL: zext64_abs16:
614 ; RV64I-NEXT: srai a1, a0, 63
615 ; RV64I-NEXT: xor a0, a0, a1
616 ; RV64I-NEXT: sub a0, a0, a1
619 ; RV64ZBB-LABEL: zext64_abs16:
621 ; RV64ZBB-NEXT: neg a1, a0
622 ; RV64ZBB-NEXT: max a0, a0, a1
624 %a = call i16 @llvm.abs.i16(i16 %x, i1 false)
625 %b = zext i16 %a to i64
629 define void @zext16_abs8(i8 %x, ptr %p) {
630 ; RV32I-LABEL: zext16_abs8:
632 ; RV32I-NEXT: slli a0, a0, 24
633 ; RV32I-NEXT: srai a0, a0, 24
634 ; RV32I-NEXT: srai a2, a0, 31
635 ; RV32I-NEXT: xor a0, a0, a2
636 ; RV32I-NEXT: sub a0, a0, a2
637 ; RV32I-NEXT: sh a0, 0(a1)
640 ; RV32ZBB-LABEL: zext16_abs8:
642 ; RV32ZBB-NEXT: sext.b a0, a0
643 ; RV32ZBB-NEXT: neg a2, a0
644 ; RV32ZBB-NEXT: max a0, a0, a2
645 ; RV32ZBB-NEXT: sh a0, 0(a1)
648 ; RV64I-LABEL: zext16_abs8:
650 ; RV64I-NEXT: slli a0, a0, 56
651 ; RV64I-NEXT: srai a0, a0, 56
652 ; RV64I-NEXT: srai a2, a0, 63
653 ; RV64I-NEXT: xor a0, a0, a2
654 ; RV64I-NEXT: subw a0, a0, a2
655 ; RV64I-NEXT: sh a0, 0(a1)
658 ; RV64ZBB-LABEL: zext16_abs8:
660 ; RV64ZBB-NEXT: sext.b a0, a0
661 ; RV64ZBB-NEXT: neg a2, a0
662 ; RV64ZBB-NEXT: max a0, a0, a2
663 ; RV64ZBB-NEXT: sh a0, 0(a1)
665 %a = call i8 @llvm.abs.i8(i8 %x, i1 false)
666 %b = zext i8 %a to i16