1 ; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false | FileCheck %s
3 define i32 @t1(i32 %a, i32 %b) nounwind readnone ssp {
6 ; CHECK: add w0, w1, w0
12 define i32 @t2(i32 %a, i32 %b) nounwind readnone ssp {
15 ; CHECK: udiv w0, w0, w1
17 %udiv = udiv i32 %a, %b
21 define i64 @t3(i64 %a, i64 %b) nounwind readnone ssp {
24 ; CHECK: udiv x0, x0, x1
26 %udiv = udiv i64 %a, %b
30 define i32 @t4(i32 %a, i32 %b) nounwind readnone ssp {
33 ; CHECK: sdiv w0, w0, w1
35 %sdiv = sdiv i32 %a, %b
39 define i64 @t5(i64 %a, i64 %b) nounwind readnone ssp {
42 ; CHECK: sdiv x0, x0, x1
44 %sdiv = sdiv i64 %a, %b
48 define i32 @t6(i32 %a, i32 %b) nounwind readnone ssp {
51 ; CHECK: lsl w0, w0, w1
57 define i64 @t7(i64 %a, i64 %b) nounwind readnone ssp {
60 ; CHECK: lsl x0, x0, x1
66 define i32 @t8(i32 %a, i32 %b) nounwind readnone ssp {
69 ; CHECK: lsr w0, w0, w1
71 %lshr = lshr i32 %a, %b
75 define i64 @t9(i64 %a, i64 %b) nounwind readnone ssp {
78 ; CHECK: lsr x0, x0, x1
80 %lshr = lshr i64 %a, %b
84 define i32 @t10(i32 %a, i32 %b) nounwind readnone ssp {
87 ; CHECK: asr w0, w0, w1
89 %ashr = ashr i32 %a, %b
93 define i64 @t11(i64 %a, i64 %b) nounwind readnone ssp {
96 ; CHECK: asr x0, x0, x1
98 %ashr = ashr i64 %a, %b
102 define i32 @t12(i16 %a, i32 %x) nounwind ssp {
105 ; CHECK: add w0, w1, w0, sxth
107 %c = sext i16 %a to i32
112 define i32 @t13(i16 %a, i32 %x) nounwind ssp {
115 ; CHECK: add w0, w1, w0, sxth #2
117 %c = sext i16 %a to i32
123 define i64 @t14(i16 %a, i64 %x) nounwind ssp {
126 ; CHECK: and w8, w0, #0xffff
127 ; CHECK: add x0, x1, w8, uxtw #3
129 %c = zext i16 %a to i64
136 define i64 @t15(i64 %a, i64 %x) nounwind ssp {
139 ; CHECK: add x0, x1, w0, uxtw
141 %b = and i64 %a, 4294967295
146 define i64 @t16(i64 %x) nounwind ssp {
149 ; CHECK: lsl x0, x0, #1
156 define i64 @t17(i16 %a, i64 %x) nounwind ssp {
159 ; CHECK: sxth [[REG:x[0-9]+]], w0
160 ; CHECK: neg x0, [[REG]], lsl #32
162 %tmp16 = sext i16 %a to i64
163 %tmp17 = mul i64 %tmp16, -4294967296
167 define i32 @t18(i32 %a, i32 %b) nounwind readnone ssp {
170 ; CHECK: sdiv w0, w0, w1
172 %sdiv = call i32 @llvm.aarch64.sdiv.i32(i32 %a, i32 %b)
176 define i64 @t19(i64 %a, i64 %b) nounwind readnone ssp {
179 ; CHECK: sdiv x0, x0, x1
181 %sdiv = call i64 @llvm.aarch64.sdiv.i64(i64 %a, i64 %b)
185 define i32 @t20(i32 %a, i32 %b) nounwind readnone ssp {
188 ; CHECK: udiv w0, w0, w1
190 %udiv = call i32 @llvm.aarch64.udiv.i32(i32 %a, i32 %b)
194 define i64 @t21(i64 %a, i64 %b) nounwind readnone ssp {
197 ; CHECK: udiv x0, x0, x1
199 %udiv = call i64 @llvm.aarch64.udiv.i64(i64 %a, i64 %b)
203 declare i32 @llvm.aarch64.sdiv.i32(i32, i32) nounwind readnone
204 declare i64 @llvm.aarch64.sdiv.i64(i64, i64) nounwind readnone
205 declare i32 @llvm.aarch64.udiv.i32(i32, i32) nounwind readnone
206 declare i64 @llvm.aarch64.udiv.i64(i64, i64) nounwind readnone
209 define i32 @inv_32(i32 %x) nounwind ssp {
214 %inv = xor i32 %x, -1
219 define i64 @inv_64(i64 %x) nounwind ssp {
224 %inv = xor i64 %x, -1
228 ; Multiplying by a power of two plus or minus one is better done via shift
229 ; and add/sub rather than the madd/msub instructions. The latter are 4+ cycles,
230 ; and the former are two (total for the two instruction sequence for subtract).
231 define i32 @f0(i32 %a) nounwind readnone ssp {
233 ; CHECK-NEXT: add w0, w0, w0, lsl #3
239 define i64 @f1(i64 %a) nounwind readnone ssp {
241 ; CHECK-NEXT: lsl x8, x0, #4
242 ; CHECK-NEXT: sub x0, x8, x0
244 %res = mul i64 %a, 15
248 define i32 @f2(i32 %a) nounwind readnone ssp {
250 ; CHECK-NEXT: lsl w8, w0, #3
251 ; CHECK-NEXT: sub w0, w8, w0
253 %res = mul nsw i32 %a, 7
257 define i64 @f3(i64 %a) nounwind readnone ssp {
259 ; CHECK-NEXT: add x0, x0, x0, lsl #4
261 %res = mul nsw i64 %a, 17
265 define i32 @f4(i32 %a) nounwind readnone ssp {
267 ; CHECK-NEXT: add w0, w0, w0, lsl #1