1 ; RUN: llc -mtriple=arm64-eabi < %s | FileCheck %s
4 @object = external hidden global i64, section "__DATA, __objc_ivar", align 8
8 ; CHECK: ldr xzr, [x0, #8]
10 define void @t1(i64* %object) {
11 %incdec.ptr = getelementptr inbounds i64, i64* %object, i64 1
12 %tmp = load volatile i64, i64* %incdec.ptr, align 8
16 ; base + offset (> imm9)
18 ; CHECK: sub [[ADDREG:x[0-9]+]], x0, #264
21 define void @t2(i64* %object) {
22 %incdec.ptr = getelementptr inbounds i64, i64* %object, i64 -33
23 %tmp = load volatile i64, i64* %incdec.ptr, align 8
27 ; base + unsigned offset (> imm9 and <= imm12 * size of type in bytes)
29 ; CHECK: ldr xzr, [x0, #32760]
31 define void @t3(i64* %object) {
32 %incdec.ptr = getelementptr inbounds i64, i64* %object, i64 4095
33 %tmp = load volatile i64, i64* %incdec.ptr, align 8
37 ; base + unsigned offset (> imm12 * size of type in bytes)
39 ; CHECK: mov w[[NUM:[0-9]+]], #32768
40 ; CHECK: ldr xzr, [x0, x[[NUM]]]
42 define void @t4(i64* %object) {
43 %incdec.ptr = getelementptr inbounds i64, i64* %object, i64 4096
44 %tmp = load volatile i64, i64* %incdec.ptr, align 8
50 ; CHECK: ldr xzr, [x{{[0-9]+}}, x{{[0-9]+}}, lsl #3]
52 define void @t5(i64 %a) {
53 %incdec.ptr = getelementptr inbounds i64, i64* @object, i64 %a
54 %tmp = load volatile i64, i64* %incdec.ptr, align 8
60 ; CHECK: add [[ADDREG:x[0-9]+]], x1, x0, lsl #3
61 ; CHECK-NEXT: mov w[[NUM:[0-9]+]], #32768
62 ; CHECK: ldr xzr, [x{{[0-9]+}}, x[[NUM]]]
64 define void @t6(i64 %a, i64* %object) {
65 %tmp1 = getelementptr inbounds i64, i64* %object, i64 %a
66 %incdec.ptr = getelementptr inbounds i64, i64* %tmp1, i64 4096
67 %tmp = load volatile i64, i64* %incdec.ptr, align 8
71 ; Test base + wide immediate
72 define void @t7(i64 %a) {
74 ; CHECK: mov w[[NUM:[0-9]+]], #65535
75 ; CHECK-NEXT: ldr xzr, [x0, x[[NUM]]]
76 %1 = add i64 %a, 65535 ;0xffff
77 %2 = inttoptr i64 %1 to i64*
78 %3 = load volatile i64, i64* %2, align 8
82 define void @t8(i64 %a) {
84 ; CHECK: mov [[REG:x[0-9]+]], #-4662
85 ; CHECK-NEXT: ldr xzr, [x0, [[REG]]]
86 %1 = sub i64 %a, 4662 ;-4662 is 0xffffffffffffedca
87 %2 = inttoptr i64 %1 to i64*
88 %3 = load volatile i64, i64* %2, align 8
92 define void @t9(i64 %a) {
94 ; CHECK: mov [[REG:x[0-9]+]], #-305463297
95 ; CHECK-NEXT: ldr xzr, [x0, [[REG]]]
96 %1 = add i64 -305463297, %a ;-305463297 is 0xffffffffedcaffff
97 %2 = inttoptr i64 %1 to i64*
98 %3 = load volatile i64, i64* %2, align 8
102 define void @t10(i64 %a) {
104 ; CHECK: mov [[REG:x[0-9]+]], #81909218222800896
105 ; CHECK-NEXT: ldr xzr, [x0, [[REG]]]
106 %1 = add i64 %a, 81909218222800896 ;0x123000000000000
107 %2 = inttoptr i64 %1 to i64*
108 %3 = load volatile i64, i64* %2, align 8
112 define void @t11(i64 %a) {
114 ; CHECK: mov w[[NUM:[0-9]+]], #17767
115 ; CHECK: movk w[[NUM:[0-9]+]], #291
116 ; CHECK-NEXT: ldr xzr, [x0, x[[NUM]]]
117 %1 = add i64 %a, 19088743 ;0x1234567
118 %2 = inttoptr i64 %1 to i64*
119 %3 = load volatile i64, i64* %2, align 8
123 ; Test some boundaries that should not use movz/movn/orr
124 define void @t12(i64 %a) {
126 ; CHECK: add [[REG:x[0-9]+]], x0, #4095
127 ; CHECK-NEXT: ldr xzr, {{\[}}[[REG]]]
128 %1 = add i64 %a, 4095 ;0xfff
129 %2 = inttoptr i64 %1 to i64*
130 %3 = load volatile i64, i64* %2, align 8
134 define void @t13(i64 %a) {
136 ; CHECK: sub [[REG:x[0-9]+]], x0, #4095
137 ; CHECK-NEXT: ldr xzr, {{\[}}[[REG]]]
138 %1 = add i64 %a, -4095 ;-0xfff
139 %2 = inttoptr i64 %1 to i64*
140 %3 = load volatile i64, i64* %2, align 8
144 define void @t14(i64 %a) {
146 ; CHECK: add [[REG:x[0-9]+]], x0, #291, lsl #12
147 ; CHECK-NEXT: ldr xzr, {{\[}}[[REG]]]
148 %1 = add i64 %a, 1191936 ;0x123000
149 %2 = inttoptr i64 %1 to i64*
150 %3 = load volatile i64, i64* %2, align 8
154 define void @t15(i64 %a) {
156 ; CHECK: sub [[REG:x[0-9]+]], x0, #291, lsl #12
157 ; CHECK-NEXT: ldr xzr, {{\[}}[[REG]]]
158 %1 = add i64 %a, -1191936 ;0xFFFFFFFFFFEDD000
159 %2 = inttoptr i64 %1 to i64*
160 %3 = load volatile i64, i64* %2, align 8
164 define void @t16(i64 %a) {
166 ; CHECK: ldr xzr, [x0, #28672]
167 %1 = add i64 %a, 28672 ;0x7000
168 %2 = inttoptr i64 %1 to i64*
169 %3 = load volatile i64, i64* %2, align 8
173 define void @t17(i64 %a) {
175 ; CHECK: ldur xzr, [x0, #-256]
176 %1 = add i64 %a, -256 ;-0x100
177 %2 = inttoptr i64 %1 to i64*
178 %3 = load volatile i64, i64* %2, align 8