1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -verify-machineinstrs -o - %s -mtriple=aarch64-none-linux-gnu | FileCheck --check-prefixes=CHECK,CHECK-FP %s
3 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -mattr=-fp-armv8 | FileCheck --check-prefixes=CHECK,CHECK-NOFP %s
5 @var_8bit = dso_local global i8 0
6 @var_16bit = dso_local global i16 0
7 @var_32bit = dso_local global i32 0
8 @var_64bit = dso_local global i64 0
10 @var_float = dso_local global float 0.0
11 @var_double = dso_local global double 0.0
13 define i32 @ld_s8_32() {
14 ; CHECK-LABEL: ld_s8_32:
16 ; CHECK-NEXT: adrp x8, var_8bit
17 ; CHECK-NEXT: ldrsb w0, [x8, :lo12:var_8bit]
19 %val8_sext32 = load i8, ptr @var_8bit
20 %val32_signed = sext i8 %val8_sext32 to i32
24 define i32 @ld_u8_32() {
25 ; CHECK-LABEL: ld_u8_32:
27 ; CHECK-NEXT: adrp x8, var_8bit
28 ; CHECK-NEXT: ldrb w0, [x8, :lo12:var_8bit]
30 %val8_zext32 = load i8, ptr @var_8bit
31 %val32_unsigned = zext i8 %val8_zext32 to i32
32 ret i32 %val32_unsigned
35 define i64 @ld_s8_64() {
36 ; CHECK-LABEL: ld_s8_64:
38 ; CHECK-NEXT: adrp x8, var_8bit
39 ; CHECK-NEXT: ldrsb x0, [x8, :lo12:var_8bit]
41 %val8_sext64 = load i8, ptr @var_8bit
42 %val64_signed = sext i8 %val8_sext64 to i64
46 define i64 @ld_u8_64() {
47 ; CHECK-LABEL: ld_u8_64:
49 ; CHECK-NEXT: adrp x8, var_8bit
50 ; CHECK-NEXT: ldrb w0, [x8, :lo12:var_8bit]
52 %val8_zext64 = load i8, ptr @var_8bit
53 %val64_unsigned = zext i8 %val8_zext64 to i64
54 ret i64 %val64_unsigned
57 define i8 @ld_a8_8() {
58 ; CHECK-LABEL: ld_a8_8:
60 ; CHECK-NEXT: adrp x8, var_8bit
61 ; CHECK-NEXT: ldrb w8, [x8, :lo12:var_8bit]
62 ; CHECK-NEXT: add w0, w8, #1
64 %val8_anyext = load i8, ptr @var_8bit
65 %newval8 = add i8 %val8_anyext, 1
69 define void @st_i32_8(i32 %val32) {
70 ; CHECK-LABEL: st_i32_8:
72 ; CHECK-NEXT: adrp x8, var_8bit
73 ; CHECK-NEXT: strb w0, [x8, :lo12:var_8bit]
75 %val8_trunc32 = trunc i32 %val32 to i8
76 store i8 %val8_trunc32, ptr @var_8bit
80 define void @st_i64_8(i64 %val64) {
81 ; CHECK-LABEL: st_i64_8:
83 ; CHECK-NEXT: adrp x8, var_8bit
84 ; CHECK-NEXT: strb w0, [x8, :lo12:var_8bit]
86 %val8_trunc64 = trunc i64 %val64 to i8
87 store i8 %val8_trunc64, ptr @var_8bit
92 define i32 @ld_s16_32() {
93 ; CHECK-LABEL: ld_s16_32:
95 ; CHECK-NEXT: adrp x8, var_16bit
96 ; CHECK-NEXT: ldrsh w0, [x8, :lo12:var_16bit]
98 %val16_sext32 = load i16, ptr @var_16bit
99 %val32_signed = sext i16 %val16_sext32 to i32
100 ret i32 %val32_signed
103 define i32 @ld_u16_32() {
104 ; CHECK-LABEL: ld_u16_32:
106 ; CHECK-NEXT: adrp x8, var_16bit
107 ; CHECK-NEXT: ldrh w0, [x8, :lo12:var_16bit]
109 %val16_zext32 = load i16, ptr @var_16bit
110 %val32_unsigned = zext i16 %val16_zext32 to i32
111 ret i32 %val32_unsigned
114 define i64 @ld_s16_64() {
115 ; CHECK-LABEL: ld_s16_64:
117 ; CHECK-NEXT: adrp x8, var_16bit
118 ; CHECK-NEXT: ldrsh x0, [x8, :lo12:var_16bit]
120 %val16_sext64 = load i16, ptr @var_16bit
121 %val64_signed = sext i16 %val16_sext64 to i64
122 ret i64 %val64_signed
125 define i64 @ld_u16_64() {
126 ; CHECK-LABEL: ld_u16_64:
128 ; CHECK-NEXT: adrp x8, var_16bit
129 ; CHECK-NEXT: ldrh w0, [x8, :lo12:var_16bit]
131 %val16_zext64 = load i16, ptr @var_16bit
132 %val64_unsigned = zext i16 %val16_zext64 to i64
133 ret i64 %val64_unsigned
136 define i16 @ld_a16_16() {
137 ; CHECK-LABEL: ld_a16_16:
139 ; CHECK-NEXT: adrp x8, var_16bit
140 ; CHECK-NEXT: ldrh w8, [x8, :lo12:var_16bit]
141 ; CHECK-NEXT: add w0, w8, #1
143 %val16_anyext = load i16, ptr @var_16bit
144 %newval16 = add i16 %val16_anyext, 1
148 define void @st_i32_16(i32 %val32) {
149 ; CHECK-LABEL: st_i32_16:
151 ; CHECK-NEXT: adrp x8, var_16bit
152 ; CHECK-NEXT: strh w0, [x8, :lo12:var_16bit]
154 %val16_trunc32 = trunc i32 %val32 to i16
155 store i16 %val16_trunc32, ptr @var_16bit
159 define void @st_i64_16(i64 %val64) {
160 ; CHECK-LABEL: st_i64_16:
162 ; CHECK-NEXT: adrp x8, var_16bit
163 ; CHECK-NEXT: strh w0, [x8, :lo12:var_16bit]
165 %val16_trunc64 = trunc i64 %val64 to i16
166 store i16 %val16_trunc64, ptr @var_16bit
171 define i64 @ld_s32_64() {
172 ; CHECK-LABEL: ld_s32_64:
174 ; CHECK-NEXT: adrp x8, var_32bit
175 ; CHECK-NEXT: ldrsw x0, [x8, :lo12:var_32bit]
177 %val32_sext64 = load i32, ptr @var_32bit
178 %val64_signed = sext i32 %val32_sext64 to i64
179 ret i64 %val64_signed
182 define i64 @ld_u32_64() {
183 ; CHECK-LABEL: ld_u32_64:
185 ; CHECK-NEXT: adrp x8, var_32bit
186 ; CHECK-NEXT: ldr w0, [x8, :lo12:var_32bit]
188 %val32_zext64 = load i32, ptr @var_32bit
189 %val64_unsigned = zext i32 %val32_zext64 to i64
190 ret i64 %val64_unsigned
193 define i32 @ld_a32_32() {
194 ; CHECK-LABEL: ld_a32_32:
196 ; CHECK-NEXT: adrp x8, var_32bit
197 ; CHECK-NEXT: ldr w8, [x8, :lo12:var_32bit]
198 ; CHECK-NEXT: add w0, w8, #1
200 %val32_anyext = load i32, ptr @var_32bit
201 %newval32 = add i32 %val32_anyext, 1
205 define void @st_i64_32(i64 %val64) {
206 ; CHECK-LABEL: st_i64_32:
208 ; CHECK-NEXT: adrp x8, var_32bit
209 ; CHECK-NEXT: str w0, [x8, :lo12:var_32bit]
211 %val32_trunc64 = trunc i64 %val64 to i32
212 store i32 %val32_trunc64, ptr @var_32bit
217 @arr8 = dso_local global ptr null
218 @arr16 = dso_local global ptr null
219 @arr32 = dso_local global ptr null
220 @arr64 = dso_local global ptr null
222 ; Now check that our selection copes with accesses more complex than a
223 ; single symbol. Permitted offsets should be folded into the loads and
224 ; stores. Since all forms use the same Operand it's only necessary to
225 ; check the various access-sizes involved.
227 define i8 @ld_i8_1(ptr %arr8_addr) {
228 ; CHECK-LABEL: ld_i8_1:
230 ; CHECK-NEXT: ldrb w0, [x0, #1]
232 %arr8_sub1_addr = getelementptr i8, ptr %arr8_addr, i64 1
233 %arr8_sub1 = load volatile i8, ptr %arr8_sub1_addr
237 define i8 @ld_i8_4095(ptr %arr8_addr) {
238 ; CHECK-LABEL: ld_i8_4095:
240 ; CHECK-NEXT: ldrb w0, [x0, #4095]
242 %arr8_sub4095_addr = getelementptr i8, ptr %arr8_addr, i64 4095
243 %arr8_sub4095 = load volatile i8, ptr %arr8_sub4095_addr
247 define i16 @ld_i16_1(ptr %arr16_addr) {
248 ; CHECK-LABEL: ld_i16_1:
250 ; CHECK-NEXT: ldrh w0, [x0, #2]
252 %arr16_sub1_addr = getelementptr i16, ptr %arr16_addr, i64 1
253 %arr16_sub1 = load volatile i16, ptr %arr16_sub1_addr
257 define i16 @ld_i16_4095(ptr %arr16_addr) {
258 ; CHECK-LABEL: ld_i16_4095:
260 ; CHECK-NEXT: ldrh w0, [x0, #8190]
262 %arr16_sub4095_addr = getelementptr i16, ptr %arr16_addr, i64 4095
263 %arr16_sub4095 = load volatile i16, ptr %arr16_sub4095_addr
264 ret i16 %arr16_sub4095
267 define i32 @ld_i32_1(ptr %arr32_addr) {
268 ; CHECK-LABEL: ld_i32_1:
270 ; CHECK-NEXT: ldr w0, [x0, #4]
272 %arr32_sub1_addr = getelementptr i32, ptr %arr32_addr, i64 1
273 %arr32_sub1 = load volatile i32, ptr %arr32_sub1_addr
277 define i32 @ld_i32_4095(ptr %arr32_addr) {
278 ; CHECK-LABEL: ld_i32_4095:
280 ; CHECK-NEXT: ldr w0, [x0, #16380]
282 %arr32_sub4095_addr = getelementptr i32, ptr %arr32_addr, i64 4095
283 %arr32_sub4095 = load volatile i32, ptr %arr32_sub4095_addr
284 ret i32 %arr32_sub4095
287 define i64 @ld_i64_1(ptr %arr64_addr) {
288 ; CHECK-LABEL: ld_i64_1:
290 ; CHECK-NEXT: ldr x0, [x0, #8]
292 %arr64_sub1_addr = getelementptr i64, ptr %arr64_addr, i64 1
293 %arr64_sub1 = load volatile i64, ptr %arr64_sub1_addr
297 define i64 @ld_i64_4095(ptr %arr64_addr) {
298 ; CHECK-LABEL: ld_i64_4095:
300 ; CHECK-NEXT: ldr x0, [x0, #32760]
302 %arr64_sub4095_addr = getelementptr i64, ptr %arr64_addr, i64 4095
303 %arr64_sub4095 = load volatile i64, ptr %arr64_sub4095_addr
304 ret i64 %arr64_sub4095
307 define dso_local void @ldst_float() {
308 ; CHECK-FP-LABEL: ldst_float:
309 ; CHECK-FP: // %bb.0:
310 ; CHECK-FP-NEXT: adrp x8, var_float
311 ; CHECK-FP-NEXT: ldr s0, [x8, :lo12:var_float]
312 ; CHECK-FP-NEXT: str s0, [x8, :lo12:var_float]
315 ; CHECK-NOFP-LABEL: ldst_float:
316 ; CHECK-NOFP: // %bb.0:
317 ; CHECK-NOFP-NEXT: adrp x8, var_float
318 ; CHECK-NOFP-NEXT: ldr w9, [x8, :lo12:var_float]
319 ; CHECK-NOFP-NEXT: str w9, [x8, :lo12:var_float]
320 ; CHECK-NOFP-NEXT: ret
321 %valfp = load volatile float, ptr @var_float
322 store volatile float %valfp, ptr @var_float
326 define dso_local void @ldst_double() {
327 ; CHECK-FP-LABEL: ldst_double:
328 ; CHECK-FP: // %bb.0:
329 ; CHECK-FP-NEXT: adrp x8, var_double
330 ; CHECK-FP-NEXT: ldr d0, [x8, :lo12:var_double]
331 ; CHECK-FP-NEXT: str d0, [x8, :lo12:var_double]
334 ; CHECK-NOFP-LABEL: ldst_double:
335 ; CHECK-NOFP: // %bb.0:
336 ; CHECK-NOFP-NEXT: adrp x8, var_double
337 ; CHECK-NOFP-NEXT: ldr x9, [x8, :lo12:var_double]
338 ; CHECK-NOFP-NEXT: str x9, [x8, :lo12:var_double]
339 ; CHECK-NOFP-NEXT: ret
340 %valfp = load volatile double, ptr @var_double
341 store volatile double %valfp, ptr @var_double