1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs \
3 ; RUN: -mtriple=aarch64-unknown-unknown < %s | FileCheck %s
5 declare i64 @llvm.abs.i64(i64, i1 immarg)
7 define i64 @neg_abs64(i64 %x) {
8 ; CHECK-LABEL: neg_abs64:
10 ; CHECK-NEXT: cmp x0, #0
11 ; CHECK-NEXT: cneg x8, x0, mi
12 ; CHECK-NEXT: neg x0, x8
14 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
15 %neg = sub nsw i64 0, %abs
19 declare i32 @llvm.abs.i32(i32, i1 immarg)
21 define i32 @neg_abs32(i32 %x) {
22 ; CHECK-LABEL: neg_abs32:
24 ; CHECK-NEXT: cmp w0, #0
25 ; CHECK-NEXT: cneg w8, w0, mi
26 ; CHECK-NEXT: neg w0, w8
28 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
29 %neg = sub nsw i32 0, %abs
33 declare i16 @llvm.abs.i16(i16, i1 immarg)
35 define i16 @neg_abs16(i16 %x) {
36 ; CHECK-LABEL: neg_abs16:
38 ; CHECK-NEXT: sbfx w8, w0, #15, #1
39 ; CHECK-NEXT: eor w9, w0, w8
40 ; CHECK-NEXT: sub w0, w8, w9
42 %abs = tail call i16 @llvm.abs.i16(i16 %x, i1 true)
43 %neg = sub nsw i16 0, %abs
48 declare i128 @llvm.abs.i128(i128, i1 immarg)
50 define i128 @neg_abs128(i128 %x) {
51 ; CHECK-LABEL: neg_abs128:
53 ; CHECK-NEXT: asr x8, x1, #63
54 ; CHECK-NEXT: eor x10, x0, x8
55 ; CHECK-NEXT: eor x9, x1, x8
56 ; CHECK-NEXT: subs x0, x8, x10
57 ; CHECK-NEXT: sbcs x1, x8, x9
59 %abs = tail call i128 @llvm.abs.i128(i128 %x, i1 true)
60 %neg = sub nsw i128 0, %abs
66 define i64 @abs64(i64 %x) {
69 ; CHECK-NEXT: cmp x0, #0
70 ; CHECK-NEXT: cneg x0, x0, mi
72 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
76 define i32 @abs32(i32 %x) {
79 ; CHECK-NEXT: cmp w0, #0
80 ; CHECK-NEXT: cneg w0, w0, mi
82 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
86 define i16 @abs16(i16 %x) {
89 ; CHECK-NEXT: sxth w8, w0
90 ; CHECK-NEXT: cmp w8, #0
91 ; CHECK-NEXT: cneg w0, w8, mi
93 %abs = tail call i16 @llvm.abs.i16(i16 %x, i1 true)
97 define i128 @abs128(i128 %x) {
98 ; CHECK-LABEL: abs128:
100 ; CHECK-NEXT: negs x8, x0
101 ; CHECK-NEXT: ngcs x9, x1
102 ; CHECK-NEXT: cmp x1, #0
103 ; CHECK-NEXT: csel x0, x8, x0, lt
104 ; CHECK-NEXT: csel x1, x9, x1, lt
106 %abs = tail call i128 @llvm.abs.i128(i128 %x, i1 true)