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 x0, x0, pl
13 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
14 %neg = sub nsw i64 0, %abs
18 declare i32 @llvm.abs.i32(i32, i1 immarg)
20 define i32 @neg_abs32(i32 %x) {
21 ; CHECK-LABEL: neg_abs32:
23 ; CHECK-NEXT: cmp w0, #0
24 ; CHECK-NEXT: cneg w0, w0, pl
26 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
27 %neg = sub nsw i32 0, %abs
31 declare i16 @llvm.abs.i16(i16, i1 immarg)
33 define i16 @neg_abs16(i16 %x) {
34 ; CHECK-LABEL: neg_abs16:
36 ; CHECK-NEXT: sbfx w8, w0, #15, #1
37 ; CHECK-NEXT: eor w9, w0, w8
38 ; CHECK-NEXT: sub w0, w8, w9
40 %abs = tail call i16 @llvm.abs.i16(i16 %x, i1 true)
41 %neg = sub nsw i16 0, %abs
46 declare i128 @llvm.abs.i128(i128, i1 immarg)
48 define i128 @neg_abs128(i128 %x) {
49 ; CHECK-LABEL: neg_abs128:
51 ; CHECK-NEXT: asr x8, x1, #63
52 ; CHECK-NEXT: eor x9, x0, x8
53 ; CHECK-NEXT: eor x10, x1, x8
54 ; CHECK-NEXT: subs x0, x8, x9
55 ; CHECK-NEXT: sbc x1, x8, x10
57 %abs = tail call i128 @llvm.abs.i128(i128 %x, i1 true)
58 %neg = sub nsw i128 0, %abs
64 define i64 @abs64(i64 %x) {
67 ; CHECK-NEXT: cmp x0, #0
68 ; CHECK-NEXT: cneg x0, x0, mi
70 %abs = tail call i64 @llvm.abs.i64(i64 %x, i1 true)
74 define i32 @abs32(i32 %x) {
77 ; CHECK-NEXT: cmp w0, #0
78 ; CHECK-NEXT: cneg w0, w0, mi
80 %abs = tail call i32 @llvm.abs.i32(i32 %x, i1 true)
84 define i16 @abs16(i16 %x) {
87 ; CHECK-NEXT: sxth w8, w0
88 ; CHECK-NEXT: cmp w8, #0
89 ; CHECK-NEXT: cneg w0, w8, mi
91 %abs = tail call i16 @llvm.abs.i16(i16 %x, i1 true)
95 define i128 @abs128(i128 %x) {
96 ; CHECK-LABEL: abs128:
98 ; CHECK-NEXT: asr x8, x1, #63
99 ; CHECK-NEXT: eor x9, x0, x8
100 ; CHECK-NEXT: eor x10, x1, x8
101 ; CHECK-NEXT: subs x0, x9, x8
102 ; CHECK-NEXT: sbc x1, x10, x8
104 %abs = tail call i128 @llvm.abs.i128(i128 %x, i1 true)