1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-SDAG
3 ; RUN: llc -global-isel -global-isel-abort=1 -verify-machineinstrs -o - %s -mtriple=aarch64-linux-gnu | FileCheck %s --check-prefixes=CHECK,CHECK-GISEL
8 define void @rev_i32() {
9 ; CHECK-LABEL: rev_i32:
11 ; CHECK-NEXT: adrp x8, :got:var32
12 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
13 ; CHECK-NEXT: ldr w9, [x8]
14 ; CHECK-NEXT: rev w9, w9
15 ; CHECK-NEXT: str w9, [x8]
17 %val0_tmp = load i32, ptr @var32
18 %val1_tmp = call i32 @llvm.bswap.i32(i32 %val0_tmp)
19 store volatile i32 %val1_tmp, ptr @var32
23 define void @rev_i64() {
24 ; CHECK-LABEL: rev_i64:
26 ; CHECK-NEXT: adrp x8, :got:var64
27 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
28 ; CHECK-NEXT: ldr x9, [x8]
29 ; CHECK-NEXT: rev x9, x9
30 ; CHECK-NEXT: str x9, [x8]
32 %val0_tmp = load i64, ptr @var64
33 %val1_tmp = call i64 @llvm.bswap.i64(i64 %val0_tmp)
34 store volatile i64 %val1_tmp, ptr @var64
38 define void @rev32_i64() {
39 ; CHECK-LABEL: rev32_i64:
41 ; CHECK-NEXT: adrp x8, :got:var64
42 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
43 ; CHECK-NEXT: ldr x9, [x8]
44 ; CHECK-NEXT: rev32 x9, x9
45 ; CHECK-NEXT: str x9, [x8]
47 %val0_tmp = load i64, ptr @var64
48 %val1_tmp = shl i64 %val0_tmp, 32
49 %val5_tmp = sub i64 64, 32
50 %val2_tmp = lshr i64 %val0_tmp, %val5_tmp
51 %val3_tmp = or i64 %val1_tmp, %val2_tmp
52 %val4_tmp = call i64 @llvm.bswap.i64(i64 %val3_tmp)
53 store volatile i64 %val4_tmp, ptr @var64
57 define void @rev16_i32() {
58 ; CHECK-LABEL: rev16_i32:
60 ; CHECK-NEXT: adrp x8, :got:var32
61 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
62 ; CHECK-NEXT: ldr w9, [x8]
63 ; CHECK-NEXT: rev16 w9, w9
64 ; CHECK-NEXT: str w9, [x8]
66 %val0_tmp = load i32, ptr @var32
67 %val1_tmp = shl i32 %val0_tmp, 16
68 %val2_tmp = lshr i32 %val0_tmp, 16
69 %val3_tmp = or i32 %val1_tmp, %val2_tmp
70 %val4_tmp = call i32 @llvm.bswap.i32(i32 %val3_tmp)
71 store volatile i32 %val4_tmp, ptr @var32
75 define void @clz_zerodef_i32() {
76 ; CHECK-LABEL: clz_zerodef_i32:
78 ; CHECK-NEXT: adrp x8, :got:var32
79 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
80 ; CHECK-NEXT: ldr w9, [x8]
81 ; CHECK-NEXT: clz w9, w9
82 ; CHECK-NEXT: str w9, [x8]
84 %val0_tmp = load i32, ptr @var32
85 %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 0)
86 store volatile i32 %val4_tmp, ptr @var32
90 define void @clz_zerodef_i64() {
91 ; CHECK-LABEL: clz_zerodef_i64:
93 ; CHECK-NEXT: adrp x8, :got:var64
94 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
95 ; CHECK-NEXT: ldr x9, [x8]
96 ; CHECK-NEXT: clz x9, x9
97 ; CHECK-NEXT: str x9, [x8]
99 %val0_tmp = load i64, ptr @var64
100 %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 0)
101 store volatile i64 %val4_tmp, ptr @var64
105 define void @clz_zeroundef_i32() {
106 ; CHECK-LABEL: clz_zeroundef_i32:
108 ; CHECK-NEXT: adrp x8, :got:var32
109 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
110 ; CHECK-NEXT: ldr w9, [x8]
111 ; CHECK-NEXT: clz w9, w9
112 ; CHECK-NEXT: str w9, [x8]
114 %val0_tmp = load i32, ptr @var32
115 %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 1)
116 store volatile i32 %val4_tmp, ptr @var32
120 define void @clz_zeroundef_i64() {
121 ; CHECK-LABEL: clz_zeroundef_i64:
123 ; CHECK-NEXT: adrp x8, :got:var64
124 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
125 ; CHECK-NEXT: ldr x9, [x8]
126 ; CHECK-NEXT: clz x9, x9
127 ; CHECK-NEXT: str x9, [x8]
129 %val0_tmp = load i64, ptr @var64
130 %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 1)
131 store volatile i64 %val4_tmp, ptr @var64
135 define void @cttz_zerodef_i32() {
136 ; CHECK-LABEL: cttz_zerodef_i32:
138 ; CHECK-NEXT: adrp x8, :got:var32
139 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
140 ; CHECK-NEXT: ldr w9, [x8]
141 ; CHECK-NEXT: rbit w9, w9
142 ; CHECK-NEXT: clz w9, w9
143 ; CHECK-NEXT: str w9, [x8]
145 %val0_tmp = load i32, ptr @var32
146 %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 0)
147 store volatile i32 %val4_tmp, ptr @var32
151 define void @cttz_zerodef_i64() {
152 ; CHECK-LABEL: cttz_zerodef_i64:
154 ; CHECK-NEXT: adrp x8, :got:var64
155 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
156 ; CHECK-NEXT: ldr x9, [x8]
157 ; CHECK-NEXT: rbit x9, x9
158 ; CHECK-NEXT: clz x9, x9
159 ; CHECK-NEXT: str x9, [x8]
161 %val0_tmp = load i64, ptr @var64
162 %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 0)
163 store volatile i64 %val4_tmp, ptr @var64
167 define void @cttz_zeroundef_i32() {
168 ; CHECK-LABEL: cttz_zeroundef_i32:
170 ; CHECK-NEXT: adrp x8, :got:var32
171 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
172 ; CHECK-NEXT: ldr w9, [x8]
173 ; CHECK-NEXT: rbit w9, w9
174 ; CHECK-NEXT: clz w9, w9
175 ; CHECK-NEXT: str w9, [x8]
177 %val0_tmp = load i32, ptr @var32
178 %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 1)
179 store volatile i32 %val4_tmp, ptr @var32
183 define void @cttz_zeroundef_i64() {
184 ; CHECK-LABEL: cttz_zeroundef_i64:
186 ; CHECK-NEXT: adrp x8, :got:var64
187 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var64]
188 ; CHECK-NEXT: ldr x9, [x8]
189 ; CHECK-NEXT: rbit x9, x9
190 ; CHECK-NEXT: clz x9, x9
191 ; CHECK-NEXT: str x9, [x8]
193 %val0_tmp = load i64, ptr @var64
194 %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 1)
195 store volatile i64 %val4_tmp, ptr @var64
199 define void @ctpop_i32() {
200 ; CHECK-LABEL: ctpop_i32:
202 ; CHECK-NEXT: adrp x8, :got:var32
203 ; CHECK-NEXT: ldr x8, [x8, :got_lo12:var32]
204 ; CHECK-NEXT: ldr w9, [x8]
205 ; CHECK-NEXT: fmov d0, x9
206 ; CHECK-NEXT: cnt v0.8b, v0.8b
207 ; CHECK-NEXT: uaddlv h0, v0.8b
208 ; CHECK-NEXT: str s0, [x8]
210 %val0_tmp = load i32, ptr @var32
211 %val4_tmp = call i32 @llvm.ctpop.i32(i32 %val0_tmp)
212 store volatile i32 %val4_tmp, ptr @var32
216 define void @ctpop_i64() {
217 ; CHECK-SDAG-LABEL: ctpop_i64:
218 ; CHECK-SDAG: // %bb.0:
219 ; CHECK-SDAG-NEXT: adrp x8, :got:var64
220 ; CHECK-SDAG-NEXT: ldr x8, [x8, :got_lo12:var64]
221 ; CHECK-SDAG-NEXT: ldr d0, [x8]
222 ; CHECK-SDAG-NEXT: cnt v0.8b, v0.8b
223 ; CHECK-SDAG-NEXT: uaddlv h0, v0.8b
224 ; CHECK-SDAG-NEXT: fmov w9, s0
225 ; CHECK-SDAG-NEXT: str x9, [x8]
226 ; CHECK-SDAG-NEXT: ret
228 ; CHECK-GISEL-LABEL: ctpop_i64:
229 ; CHECK-GISEL: // %bb.0:
230 ; CHECK-GISEL-NEXT: adrp x8, :got:var64
231 ; CHECK-GISEL-NEXT: ldr x8, [x8, :got_lo12:var64]
232 ; CHECK-GISEL-NEXT: ldr x9, [x8]
233 ; CHECK-GISEL-NEXT: fmov d0, x9
234 ; CHECK-GISEL-NEXT: cnt v0.8b, v0.8b
235 ; CHECK-GISEL-NEXT: uaddlv h0, v0.8b
236 ; CHECK-GISEL-NEXT: mov w9, v0.s[0]
237 ; CHECK-GISEL-NEXT: str x9, [x8]
238 ; CHECK-GISEL-NEXT: ret
239 %val0_tmp = load i64, ptr @var64
240 %val4_tmp = call i64 @llvm.ctpop.i64(i64 %val0_tmp)
241 store volatile i64 %val4_tmp, ptr @var64
246 declare i32 @llvm.bswap.i32(i32)
247 declare i64 @llvm.bswap.i64(i64)
248 declare i32 @llvm.ctlz.i32 (i32, i1)
249 declare i64 @llvm.ctlz.i64 (i64, i1)
250 declare i32 @llvm.cttz.i32 (i32, i1)
251 declare i64 @llvm.cttz.i64 (i64, i1)
252 declare i32 @llvm.ctpop.i32 (i32)
253 declare i64 @llvm.ctpop.i64 (i64)