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: add x0, x1, w0, uxth #3
128 %c = zext i16 %a to i64
135 define i64 @t15(i64 %a, i64 %x) nounwind ssp {
138 ; CHECK: add x0, x1, w0, uxtw
140 %b = and i64 %a, 4294967295
145 define i64 @t16(i64 %x) nounwind ssp {
148 ; CHECK: lsl x0, x0, #1
155 define i64 @t17(i16 %a, i64 %x) nounwind ssp {
158 ; CHECK: sxth [[REG:x[0-9]+]], w0
159 ; CHECK: neg x0, [[REG]], lsl #32
161 %tmp16 = sext i16 %a to i64
162 %tmp17 = mul i64 %tmp16, -4294967296
166 define i32 @t18(i32 %a, i32 %b) nounwind readnone ssp {
169 ; CHECK: sdiv w0, w0, w1
171 %sdiv = call i32 @llvm.aarch64.sdiv.i32(i32 %a, i32 %b)
175 define i64 @t19(i64 %a, i64 %b) nounwind readnone ssp {
178 ; CHECK: sdiv x0, x0, x1
180 %sdiv = call i64 @llvm.aarch64.sdiv.i64(i64 %a, i64 %b)
184 define i32 @t20(i32 %a, i32 %b) nounwind readnone ssp {
187 ; CHECK: udiv w0, w0, w1
189 %udiv = call i32 @llvm.aarch64.udiv.i32(i32 %a, i32 %b)
193 define i64 @t21(i64 %a, i64 %b) nounwind readnone ssp {
196 ; CHECK: udiv x0, x0, x1
198 %udiv = call i64 @llvm.aarch64.udiv.i64(i64 %a, i64 %b)
202 declare i32 @llvm.aarch64.sdiv.i32(i32, i32) nounwind readnone
203 declare i64 @llvm.aarch64.sdiv.i64(i64, i64) nounwind readnone
204 declare i32 @llvm.aarch64.udiv.i32(i32, i32) nounwind readnone
205 declare i64 @llvm.aarch64.udiv.i64(i64, i64) nounwind readnone
208 define i32 @inv_32(i32 %x) nounwind ssp {
213 %inv = xor i32 %x, -1
218 define i64 @inv_64(i64 %x) nounwind ssp {
223 %inv = xor i64 %x, -1
227 ; Multiplying by a power of two plus or minus one is better done via shift
228 ; and add/sub rather than the madd/msub instructions. The latter are 4+ cycles,
229 ; and the former are two (total for the two instruction sequence for subtract).
230 define i32 @f0(i32 %a) nounwind readnone ssp {
232 ; CHECK-NEXT: add w0, w0, w0, lsl #3
238 define i64 @f1(i64 %a) nounwind readnone ssp {
240 ; CHECK-NEXT: lsl x8, x0, #4
241 ; CHECK-NEXT: sub x0, x8, x0
243 %res = mul i64 %a, 15
247 define i32 @f2(i32 %a) nounwind readnone ssp {
249 ; CHECK-NEXT: lsl w8, w0, #3
250 ; CHECK-NEXT: sub w0, w8, w0
252 %res = mul nsw i32 %a, 7
256 define i64 @f3(i64 %a) nounwind readnone ssp {
258 ; CHECK-NEXT: add x0, x0, x0, lsl #4
260 %res = mul nsw i64 %a, 17
264 define i32 @f4(i32 %a) nounwind readnone ssp {
266 ; CHECK-NEXT: add w0, w0, w0, lsl #1