1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=aarch64-linux-gnu -O2 -o - %s | FileCheck %s
4 define i64 @test_ssub_nonneg_rhs(i64 %x) {
5 ; CHECK-LABEL: test_ssub_nonneg_rhs:
7 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
8 ; CHECK-NEXT: subs x9, x0, #1
9 ; CHECK-NEXT: csel x0, x8, x9, vs
11 %sat = call i64 @llvm.ssub.sat.i64(i64 %x, i64 1)
15 define i64 @test_ssub_neg_rhs(i64 %x) {
16 ; CHECK-LABEL: test_ssub_neg_rhs:
18 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
19 ; CHECK-NEXT: adds x9, x0, #1
20 ; CHECK-NEXT: csel x0, x8, x9, vs
22 %sat = call i64 @llvm.ssub.sat.i64(i64 %x, i64 -1)
26 define i64 @test_sadd_nonneg_rhs(i64 %x) {
27 ; CHECK-LABEL: test_sadd_nonneg_rhs:
29 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
30 ; CHECK-NEXT: adds x9, x0, #1
31 ; CHECK-NEXT: csel x0, x8, x9, vs
33 %sat = call i64 @llvm.sadd.sat.i64(i64 %x, i64 1)
38 define i64 @test_sadd_neg_rhs(i64 %x) {
39 ; CHECK-LABEL: test_sadd_neg_rhs:
41 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
42 ; CHECK-NEXT: subs x9, x0, #1
43 ; CHECK-NEXT: csel x0, x8, x9, vs
45 %sat = call i64 @llvm.sadd.sat.i64(i64 %x, i64 -1)
49 define i64 @test_ssub_nonneg_lhs(i64 %x) {
50 ; CHECK-LABEL: test_ssub_nonneg_lhs:
52 ; CHECK-NEXT: mov w8, #1 // =0x1
53 ; CHECK-NEXT: mov x9, #9223372036854775807 // =0x7fffffffffffffff
54 ; CHECK-NEXT: subs x8, x8, x0
55 ; CHECK-NEXT: csel x0, x9, x8, vs
57 %sat = call i64 @llvm.ssub.sat.i64(i64 1, i64 %x)
61 define i64 @test_ssub_neg_lhs(i64 %x) {
62 ; CHECK-LABEL: test_ssub_neg_lhs:
64 ; CHECK-NEXT: mvn x0, x0
66 %sat = call i64 @llvm.ssub.sat.i64(i64 -1, i64 %x)
70 define i64 @test_sadd_nonneg_lhs(i64 %x) {
71 ; CHECK-LABEL: test_sadd_nonneg_lhs:
73 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
74 ; CHECK-NEXT: adds x9, x0, #1
75 ; CHECK-NEXT: csel x0, x8, x9, vs
77 %sat = call i64 @llvm.sadd.sat.i64(i64 1, i64 %x)
81 define i64 @test_sadd_neg_lhs(i64 %x) {
82 ; CHECK-LABEL: test_sadd_neg_lhs:
84 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
85 ; CHECK-NEXT: subs x9, x0, #1
86 ; CHECK-NEXT: csel x0, x8, x9, vs
88 %sat = call i64 @llvm.sadd.sat.i64(i64 -1, i64 %x)
92 define i64 @test_ssub_nonneg_rhs_nonconst(i64 %x) {
93 ; CHECK-LABEL: test_ssub_nonneg_rhs_nonconst:
95 ; CHECK-NEXT: mov w8, #123 // =0x7b
96 ; CHECK-NEXT: mov x9, #-9223372036854775808 // =0x8000000000000000
97 ; CHECK-NEXT: and x8, x0, x8
98 ; CHECK-NEXT: subs x8, x0, x8
99 ; CHECK-NEXT: csel x0, x9, x8, vs
102 %sat = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %y)
106 define i64 @test_ssub_neg_rhs_nonconst(i64 %x) {
107 ; CHECK-LABEL: test_ssub_neg_rhs_nonconst:
109 ; CHECK-NEXT: cmn x0, #1
110 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
111 ; CHECK-NEXT: csinv x9, x0, xzr, lt
112 ; CHECK-NEXT: subs x9, x0, x9
113 ; CHECK-NEXT: csel x0, x8, x9, vs
115 %y = call i64 @llvm.smin(i64 %x, i64 -1)
116 %sat = call i64 @llvm.ssub.sat.i64(i64 %x, i64 %y)
120 define i64 @test_sadd_nonneg_rhs_nonconst(i64 %x) {
121 ; CHECK-LABEL: test_sadd_nonneg_rhs_nonconst:
123 ; CHECK-NEXT: cmp x0, #1
124 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
125 ; CHECK-NEXT: csinc x9, x0, xzr, gt
126 ; CHECK-NEXT: adds x9, x0, x9
127 ; CHECK-NEXT: csel x0, x8, x9, vs
129 %y = call i64 @llvm.smax(i64 %x, i64 1)
130 %sat = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y)
135 define i64 @test_sadd_neg_rhs_nonconst(i64 %x) {
136 ; CHECK-LABEL: test_sadd_neg_rhs_nonconst:
138 ; CHECK-NEXT: orr x9, x0, #0x8000000000000000
139 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
140 ; CHECK-NEXT: adds x9, x0, x9
141 ; CHECK-NEXT: csel x0, x8, x9, vs
143 %y = or i64 %x, u0x8000000000000000
144 %sat = call i64 @llvm.sadd.sat.i64(i64 %x, i64 %y)
148 define i64 @test_ssub_nonneg_lhs_nonconst(i64 %x) {
149 ; CHECK-LABEL: test_ssub_nonneg_lhs_nonconst:
151 ; CHECK-NEXT: mov w8, #123 // =0x7b
152 ; CHECK-NEXT: mov x9, #9223372036854775807 // =0x7fffffffffffffff
153 ; CHECK-NEXT: and x8, x0, x8
154 ; CHECK-NEXT: subs x8, x8, x0
155 ; CHECK-NEXT: csel x0, x9, x8, vs
158 %sat = call i64 @llvm.ssub.sat.i64(i64 %y, i64 %x)
162 define i64 @test_ssub_neg_lhs_nonconst(i64 %x) {
163 ; CHECK-LABEL: test_ssub_neg_lhs_nonconst:
165 ; CHECK-NEXT: cmn x0, #1
166 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
167 ; CHECK-NEXT: csinv x9, x0, xzr, lt
168 ; CHECK-NEXT: subs x9, x9, x0
169 ; CHECK-NEXT: csel x0, x8, x9, vs
171 %y = call i64 @llvm.smin(i64 %x, i64 -1)
172 %sat = call i64 @llvm.ssub.sat.i64(i64 %y, i64 %x)
176 define i64 @test_sadd_nonneg_lhs_nonconst(i64 %x) {
177 ; CHECK-LABEL: test_sadd_nonneg_lhs_nonconst:
179 ; CHECK-NEXT: cmp x0, #1
180 ; CHECK-NEXT: mov x8, #9223372036854775807 // =0x7fffffffffffffff
181 ; CHECK-NEXT: csinc x9, x0, xzr, gt
182 ; CHECK-NEXT: adds x9, x9, x0
183 ; CHECK-NEXT: csel x0, x8, x9, vs
185 %y = call i64 @llvm.smax(i64 %x, i64 1)
186 %sat = call i64 @llvm.sadd.sat.i64(i64 %y, i64 %x)
190 define i64 @test_sadd_neg_lhs_nonconst(i64 %x) {
191 ; CHECK-LABEL: test_sadd_neg_lhs_nonconst:
193 ; CHECK-NEXT: orr x9, x0, #0x8000000000000000
194 ; CHECK-NEXT: mov x8, #-9223372036854775808 // =0x8000000000000000
195 ; CHECK-NEXT: adds x9, x9, x0
196 ; CHECK-NEXT: csel x0, x8, x9, vs
198 %y = or i64 %x, u0x8000000000000000
199 %sat = call i64 @llvm.sadd.sat.i64(i64 %y, i64 %x)
203 declare i64 @llvm.sadd.sat.i64(i64, i64)
204 declare i64 @llvm.ssub.sat.i64(i64, i64)
205 declare i64 @llvm.smax(i64, i64)
206 declare i64 @llvm.smin(i64, i64)