1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --relocation-model=pic \
3 ; RUN: --verify-machineinstrs < %s | FileCheck -check-prefixes=LA32 %s
4 ; RUN: llc --mtriple=loongarch64 --relocation-model=pic \
5 ; RUN: --verify-machineinstrs < %s | FileCheck -check-prefixes=LA64 %s
6 ; RUN: llc --mtriple=loongarch64 --relocation-model=pic --code-model=large \
7 ; RUN: --verify-machineinstrs < %s | FileCheck -check-prefixes=LA64LARGE %s
9 ; Verifies that MachineLICM can hoist address generation pseudos out of loops.
11 @l = protected global i32 0, align 4
13 define void @test_la_pcrel(i32 signext %n) {
14 ; LA32-LABEL: test_la_pcrel:
15 ; LA32: # %bb.0: # %entry
16 ; LA32-NEXT: move $a1, $zero
17 ; LA32-NEXT: pcalau12i $a2, %pc_hi20(l)
18 ; LA32-NEXT: .p2align 4, , 16
19 ; LA32-NEXT: .LBB0_1: # %loop
20 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
21 ; LA32-NEXT: ld.w $zero, $a2, %pc_lo12(l)
22 ; LA32-NEXT: addi.w $a1, $a1, 1
23 ; LA32-NEXT: blt $a1, $a0, .LBB0_1
24 ; LA32-NEXT: # %bb.2: # %ret
27 ; LA64-LABEL: test_la_pcrel:
28 ; LA64: # %bb.0: # %entry
29 ; LA64-NEXT: move $a1, $zero
30 ; LA64-NEXT: pcalau12i $a2, %pc_hi20(l)
31 ; LA64-NEXT: .p2align 4, , 16
32 ; LA64-NEXT: .LBB0_1: # %loop
33 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
34 ; LA64-NEXT: ld.w $zero, $a2, %pc_lo12(l)
35 ; LA64-NEXT: addi.w $a1, $a1, 1
36 ; LA64-NEXT: blt $a1, $a0, .LBB0_1
37 ; LA64-NEXT: # %bb.2: # %ret
40 ; LA64LARGE-LABEL: test_la_pcrel:
41 ; LA64LARGE: # %bb.0: # %entry
42 ; LA64LARGE-NEXT: pcalau12i $a1, %pc_hi20(l)
43 ; LA64LARGE-NEXT: addi.d $a2, $zero, %pc_lo12(l)
44 ; LA64LARGE-NEXT: lu32i.d $a2, %pc64_lo20(l)
45 ; LA64LARGE-NEXT: lu52i.d $a2, $a2, %pc64_hi12(l)
46 ; LA64LARGE-NEXT: move $a3, $zero
47 ; LA64LARGE-NEXT: .p2align 4, , 16
48 ; LA64LARGE-NEXT: .LBB0_1: # %loop
49 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
50 ; LA64LARGE-NEXT: ldx.w $zero, $a2, $a1
51 ; LA64LARGE-NEXT: addi.w $a3, $a3, 1
52 ; LA64LARGE-NEXT: blt $a3, $a0, .LBB0_1
53 ; LA64LARGE-NEXT: # %bb.2: # %ret
59 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
60 %0 = load volatile i32, ptr @l, align 4
61 %inc = add nuw nsw i32 %i, 1
62 %cmp = icmp slt i32 %inc, %n
63 br i1 %cmp, label %loop, label %ret
69 @g = global i32 0, align 4
71 define void @test_la_got(i32 signext %n) {
72 ; LA32-LABEL: test_la_got:
73 ; LA32: # %bb.0: # %entry
74 ; LA32-NEXT: pcalau12i $a1, %got_pc_hi20(g)
75 ; LA32-NEXT: ld.w $a1, $a1, %got_pc_lo12(g)
76 ; LA32-NEXT: move $a2, $zero
77 ; LA32-NEXT: .p2align 4, , 16
78 ; LA32-NEXT: .LBB1_1: # %loop
79 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
80 ; LA32-NEXT: ld.w $zero, $a1, 0
81 ; LA32-NEXT: addi.w $a2, $a2, 1
82 ; LA32-NEXT: blt $a2, $a0, .LBB1_1
83 ; LA32-NEXT: # %bb.2: # %ret
86 ; LA64-LABEL: test_la_got:
87 ; LA64: # %bb.0: # %entry
88 ; LA64-NEXT: pcalau12i $a1, %got_pc_hi20(g)
89 ; LA64-NEXT: ld.d $a1, $a1, %got_pc_lo12(g)
90 ; LA64-NEXT: move $a2, $zero
91 ; LA64-NEXT: .p2align 4, , 16
92 ; LA64-NEXT: .LBB1_1: # %loop
93 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
94 ; LA64-NEXT: ld.w $zero, $a1, 0
95 ; LA64-NEXT: addi.w $a2, $a2, 1
96 ; LA64-NEXT: blt $a2, $a0, .LBB1_1
97 ; LA64-NEXT: # %bb.2: # %ret
100 ; LA64LARGE-LABEL: test_la_got:
101 ; LA64LARGE: # %bb.0: # %entry
102 ; LA64LARGE-NEXT: pcalau12i $a1, %got_pc_hi20(g)
103 ; LA64LARGE-NEXT: addi.d $a2, $zero, %got_pc_lo12(g)
104 ; LA64LARGE-NEXT: lu32i.d $a2, %got64_pc_lo20(g)
105 ; LA64LARGE-NEXT: lu52i.d $a2, $a2, %got64_pc_hi12(g)
106 ; LA64LARGE-NEXT: ldx.d $a1, $a2, $a1
107 ; LA64LARGE-NEXT: move $a2, $zero
108 ; LA64LARGE-NEXT: .p2align 4, , 16
109 ; LA64LARGE-NEXT: .LBB1_1: # %loop
110 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
111 ; LA64LARGE-NEXT: ld.w $zero, $a1, 0
112 ; LA64LARGE-NEXT: addi.w $a2, $a2, 1
113 ; LA64LARGE-NEXT: blt $a2, $a0, .LBB1_1
114 ; LA64LARGE-NEXT: # %bb.2: # %ret
115 ; LA64LARGE-NEXT: ret
120 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
121 %0 = load volatile i32, ptr @g, align 4
122 %inc = add nuw nsw i32 %i, 1
123 %cmp = icmp slt i32 %inc, %n
124 br i1 %cmp, label %loop, label %ret
130 @ie = external thread_local(initialexec) global i32
132 define void @test_la_tls_ie(i32 signext %n) {
133 ; LA32-LABEL: test_la_tls_ie:
134 ; LA32: # %bb.0: # %entry
135 ; LA32-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
136 ; LA32-NEXT: ld.w $a2, $a1, %ie_pc_lo12(ie)
137 ; LA32-NEXT: move $a1, $zero
138 ; LA32-NEXT: add.w $a2, $a2, $tp
139 ; LA32-NEXT: .p2align 4, , 16
140 ; LA32-NEXT: .LBB2_1: # %loop
141 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
142 ; LA32-NEXT: ld.w $zero, $a2, 0
143 ; LA32-NEXT: addi.w $a1, $a1, 1
144 ; LA32-NEXT: blt $a1, $a0, .LBB2_1
145 ; LA32-NEXT: # %bb.2: # %ret
148 ; LA64-LABEL: test_la_tls_ie:
149 ; LA64: # %bb.0: # %entry
150 ; LA64-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
151 ; LA64-NEXT: ld.d $a1, $a1, %ie_pc_lo12(ie)
152 ; LA64-NEXT: move $a2, $zero
153 ; LA64-NEXT: .p2align 4, , 16
154 ; LA64-NEXT: .LBB2_1: # %loop
155 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
156 ; LA64-NEXT: ldx.w $zero, $a1, $tp
157 ; LA64-NEXT: addi.w $a2, $a2, 1
158 ; LA64-NEXT: blt $a2, $a0, .LBB2_1
159 ; LA64-NEXT: # %bb.2: # %ret
162 ; LA64LARGE-LABEL: test_la_tls_ie:
163 ; LA64LARGE: # %bb.0: # %entry
164 ; LA64LARGE-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
165 ; LA64LARGE-NEXT: addi.d $a2, $zero, %ie_pc_lo12(ie)
166 ; LA64LARGE-NEXT: lu32i.d $a2, %ie64_pc_lo20(ie)
167 ; LA64LARGE-NEXT: lu52i.d $a2, $a2, %ie64_pc_hi12(ie)
168 ; LA64LARGE-NEXT: ldx.d $a1, $a2, $a1
169 ; LA64LARGE-NEXT: move $a2, $zero
170 ; LA64LARGE-NEXT: .p2align 4, , 16
171 ; LA64LARGE-NEXT: .LBB2_1: # %loop
172 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
173 ; LA64LARGE-NEXT: ldx.w $zero, $a1, $tp
174 ; LA64LARGE-NEXT: addi.w $a2, $a2, 1
175 ; LA64LARGE-NEXT: blt $a2, $a0, .LBB2_1
176 ; LA64LARGE-NEXT: # %bb.2: # %ret
177 ; LA64LARGE-NEXT: ret
182 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
183 %0 = load volatile i32, ptr @ie, align 4
184 %inc = add nuw nsw i32 %i, 1
185 %cmp = icmp slt i32 %inc, %n
186 br i1 %cmp, label %loop, label %ret
192 @ld = external thread_local(localdynamic) global i32
194 define void @test_la_tls_ld(i32 signext %n) {
195 ; LA32-LABEL: test_la_tls_ld:
196 ; LA32: # %bb.0: # %entry
197 ; LA32-NEXT: addi.w $sp, $sp, -16
198 ; LA32-NEXT: .cfi_def_cfa_offset 16
199 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
200 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
201 ; LA32-NEXT: st.w $s0, $sp, 4 # 4-byte Folded Spill
202 ; LA32-NEXT: st.w $s1, $sp, 0 # 4-byte Folded Spill
203 ; LA32-NEXT: .cfi_offset 1, -4
204 ; LA32-NEXT: .cfi_offset 22, -8
205 ; LA32-NEXT: .cfi_offset 23, -12
206 ; LA32-NEXT: .cfi_offset 24, -16
207 ; LA32-NEXT: move $fp, $a0
208 ; LA32-NEXT: move $s1, $zero
209 ; LA32-NEXT: pcalau12i $a0, %ld_pc_hi20(ld)
210 ; LA32-NEXT: addi.w $s0, $a0, %got_pc_lo12(ld)
211 ; LA32-NEXT: .p2align 4, , 16
212 ; LA32-NEXT: .LBB3_1: # %loop
213 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
214 ; LA32-NEXT: move $a0, $s0
215 ; LA32-NEXT: bl %plt(__tls_get_addr)
216 ; LA32-NEXT: ld.w $zero, $a0, 0
217 ; LA32-NEXT: addi.w $s1, $s1, 1
218 ; LA32-NEXT: blt $s1, $fp, .LBB3_1
219 ; LA32-NEXT: # %bb.2: # %ret
220 ; LA32-NEXT: ld.w $s1, $sp, 0 # 4-byte Folded Reload
221 ; LA32-NEXT: ld.w $s0, $sp, 4 # 4-byte Folded Reload
222 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
223 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
224 ; LA32-NEXT: addi.w $sp, $sp, 16
227 ; LA64-LABEL: test_la_tls_ld:
228 ; LA64: # %bb.0: # %entry
229 ; LA64-NEXT: addi.d $sp, $sp, -32
230 ; LA64-NEXT: .cfi_def_cfa_offset 32
231 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
232 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
233 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
234 ; LA64-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
235 ; LA64-NEXT: .cfi_offset 1, -8
236 ; LA64-NEXT: .cfi_offset 22, -16
237 ; LA64-NEXT: .cfi_offset 23, -24
238 ; LA64-NEXT: .cfi_offset 24, -32
239 ; LA64-NEXT: move $fp, $a0
240 ; LA64-NEXT: move $s1, $zero
241 ; LA64-NEXT: pcalau12i $a0, %ld_pc_hi20(ld)
242 ; LA64-NEXT: addi.d $s0, $a0, %got_pc_lo12(ld)
243 ; LA64-NEXT: .p2align 4, , 16
244 ; LA64-NEXT: .LBB3_1: # %loop
245 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
246 ; LA64-NEXT: move $a0, $s0
247 ; LA64-NEXT: bl %plt(__tls_get_addr)
248 ; LA64-NEXT: ld.w $zero, $a0, 0
249 ; LA64-NEXT: addi.w $s1, $s1, 1
250 ; LA64-NEXT: blt $s1, $fp, .LBB3_1
251 ; LA64-NEXT: # %bb.2: # %ret
252 ; LA64-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
253 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
254 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
255 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
256 ; LA64-NEXT: addi.d $sp, $sp, 32
259 ; LA64LARGE-LABEL: test_la_tls_ld:
260 ; LA64LARGE: # %bb.0: # %entry
261 ; LA64LARGE-NEXT: addi.d $sp, $sp, -32
262 ; LA64LARGE-NEXT: .cfi_def_cfa_offset 32
263 ; LA64LARGE-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
264 ; LA64LARGE-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
265 ; LA64LARGE-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
266 ; LA64LARGE-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
267 ; LA64LARGE-NEXT: .cfi_offset 1, -8
268 ; LA64LARGE-NEXT: .cfi_offset 22, -16
269 ; LA64LARGE-NEXT: .cfi_offset 23, -24
270 ; LA64LARGE-NEXT: .cfi_offset 24, -32
271 ; LA64LARGE-NEXT: move $fp, $a0
272 ; LA64LARGE-NEXT: pcalau12i $a0, %ld_pc_hi20(ld)
273 ; LA64LARGE-NEXT: addi.d $a1, $zero, %got_pc_lo12(ld)
274 ; LA64LARGE-NEXT: lu32i.d $a1, %got64_pc_lo20(ld)
275 ; LA64LARGE-NEXT: lu52i.d $a1, $a1, %got64_pc_hi12(ld)
276 ; LA64LARGE-NEXT: move $s1, $zero
277 ; LA64LARGE-NEXT: add.d $s0, $a1, $a0
278 ; LA64LARGE-NEXT: .p2align 4, , 16
279 ; LA64LARGE-NEXT: .LBB3_1: # %loop
280 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
281 ; LA64LARGE-NEXT: move $a0, $s0
282 ; LA64LARGE-NEXT: pcalau12i $a1, %got_pc_hi20(__tls_get_addr)
283 ; LA64LARGE-NEXT: addi.d $ra, $zero, %got_pc_lo12(__tls_get_addr)
284 ; LA64LARGE-NEXT: lu32i.d $ra, %got64_pc_lo20(__tls_get_addr)
285 ; LA64LARGE-NEXT: lu52i.d $ra, $ra, %got64_pc_hi12(__tls_get_addr)
286 ; LA64LARGE-NEXT: ldx.d $ra, $ra, $a1
287 ; LA64LARGE-NEXT: jirl $ra, $ra, 0
288 ; LA64LARGE-NEXT: ld.w $zero, $a0, 0
289 ; LA64LARGE-NEXT: addi.w $s1, $s1, 1
290 ; LA64LARGE-NEXT: blt $s1, $fp, .LBB3_1
291 ; LA64LARGE-NEXT: # %bb.2: # %ret
292 ; LA64LARGE-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
293 ; LA64LARGE-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
294 ; LA64LARGE-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
295 ; LA64LARGE-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
296 ; LA64LARGE-NEXT: addi.d $sp, $sp, 32
297 ; LA64LARGE-NEXT: ret
302 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
303 %0 = load volatile i32, ptr @ld, align 4
304 %inc = add nuw nsw i32 %i, 1
305 %cmp = icmp slt i32 %inc, %n
306 br i1 %cmp, label %loop, label %ret
312 @le = external thread_local(localexec) global i32
314 define void @test_la_tls_le(i32 signext %n) {
315 ; LA32-LABEL: test_la_tls_le:
316 ; LA32: # %bb.0: # %entry
317 ; LA32-NEXT: move $a1, $zero
318 ; LA32-NEXT: lu12i.w $a2, %le_hi20(le)
319 ; LA32-NEXT: ori $a2, $a2, %le_lo12(le)
320 ; LA32-NEXT: add.w $a2, $a2, $tp
321 ; LA32-NEXT: .p2align 4, , 16
322 ; LA32-NEXT: .LBB4_1: # %loop
323 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
324 ; LA32-NEXT: ld.w $zero, $a2, 0
325 ; LA32-NEXT: addi.w $a1, $a1, 1
326 ; LA32-NEXT: blt $a1, $a0, .LBB4_1
327 ; LA32-NEXT: # %bb.2: # %ret
330 ; LA64-LABEL: test_la_tls_le:
331 ; LA64: # %bb.0: # %entry
332 ; LA64-NEXT: move $a1, $zero
333 ; LA64-NEXT: lu12i.w $a2, %le_hi20(le)
334 ; LA64-NEXT: ori $a2, $a2, %le_lo12(le)
335 ; LA64-NEXT: .p2align 4, , 16
336 ; LA64-NEXT: .LBB4_1: # %loop
337 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
338 ; LA64-NEXT: ldx.w $zero, $a2, $tp
339 ; LA64-NEXT: addi.w $a1, $a1, 1
340 ; LA64-NEXT: blt $a1, $a0, .LBB4_1
341 ; LA64-NEXT: # %bb.2: # %ret
344 ; LA64LARGE-LABEL: test_la_tls_le:
345 ; LA64LARGE: # %bb.0: # %entry
346 ; LA64LARGE-NEXT: move $a1, $zero
347 ; LA64LARGE-NEXT: lu12i.w $a2, %le_hi20(le)
348 ; LA64LARGE-NEXT: ori $a2, $a2, %le_lo12(le)
349 ; LA64LARGE-NEXT: lu32i.d $a2, %le64_lo20(le)
350 ; LA64LARGE-NEXT: lu52i.d $a2, $a2, %le64_hi12(le)
351 ; LA64LARGE-NEXT: .p2align 4, , 16
352 ; LA64LARGE-NEXT: .LBB4_1: # %loop
353 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
354 ; LA64LARGE-NEXT: ldx.w $zero, $a2, $tp
355 ; LA64LARGE-NEXT: addi.w $a1, $a1, 1
356 ; LA64LARGE-NEXT: blt $a1, $a0, .LBB4_1
357 ; LA64LARGE-NEXT: # %bb.2: # %ret
358 ; LA64LARGE-NEXT: ret
363 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
364 %0 = load volatile i32, ptr @le, align 4
365 %inc = add nuw nsw i32 %i, 1
366 %cmp = icmp slt i32 %inc, %n
367 br i1 %cmp, label %loop, label %ret
373 @gd = external thread_local global i32
375 define void @test_la_tls_gd(i32 signext %n) nounwind {
376 ; LA32-LABEL: test_la_tls_gd:
377 ; LA32: # %bb.0: # %entry
378 ; LA32-NEXT: addi.w $sp, $sp, -16
379 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
380 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
381 ; LA32-NEXT: st.w $s0, $sp, 4 # 4-byte Folded Spill
382 ; LA32-NEXT: st.w $s1, $sp, 0 # 4-byte Folded Spill
383 ; LA32-NEXT: move $fp, $a0
384 ; LA32-NEXT: move $s1, $zero
385 ; LA32-NEXT: pcalau12i $a0, %gd_pc_hi20(gd)
386 ; LA32-NEXT: addi.w $s0, $a0, %got_pc_lo12(gd)
387 ; LA32-NEXT: .p2align 4, , 16
388 ; LA32-NEXT: .LBB5_1: # %loop
389 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
390 ; LA32-NEXT: move $a0, $s0
391 ; LA32-NEXT: bl %plt(__tls_get_addr)
392 ; LA32-NEXT: ld.w $zero, $a0, 0
393 ; LA32-NEXT: addi.w $s1, $s1, 1
394 ; LA32-NEXT: blt $s1, $fp, .LBB5_1
395 ; LA32-NEXT: # %bb.2: # %ret
396 ; LA32-NEXT: ld.w $s1, $sp, 0 # 4-byte Folded Reload
397 ; LA32-NEXT: ld.w $s0, $sp, 4 # 4-byte Folded Reload
398 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
399 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
400 ; LA32-NEXT: addi.w $sp, $sp, 16
403 ; LA64-LABEL: test_la_tls_gd:
404 ; LA64: # %bb.0: # %entry
405 ; LA64-NEXT: addi.d $sp, $sp, -32
406 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
407 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
408 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
409 ; LA64-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
410 ; LA64-NEXT: move $fp, $a0
411 ; LA64-NEXT: move $s1, $zero
412 ; LA64-NEXT: pcalau12i $a0, %gd_pc_hi20(gd)
413 ; LA64-NEXT: addi.d $s0, $a0, %got_pc_lo12(gd)
414 ; LA64-NEXT: .p2align 4, , 16
415 ; LA64-NEXT: .LBB5_1: # %loop
416 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
417 ; LA64-NEXT: move $a0, $s0
418 ; LA64-NEXT: bl %plt(__tls_get_addr)
419 ; LA64-NEXT: ld.w $zero, $a0, 0
420 ; LA64-NEXT: addi.w $s1, $s1, 1
421 ; LA64-NEXT: blt $s1, $fp, .LBB5_1
422 ; LA64-NEXT: # %bb.2: # %ret
423 ; LA64-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
424 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
425 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
426 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
427 ; LA64-NEXT: addi.d $sp, $sp, 32
430 ; LA64LARGE-LABEL: test_la_tls_gd:
431 ; LA64LARGE: # %bb.0: # %entry
432 ; LA64LARGE-NEXT: addi.d $sp, $sp, -32
433 ; LA64LARGE-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
434 ; LA64LARGE-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
435 ; LA64LARGE-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
436 ; LA64LARGE-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
437 ; LA64LARGE-NEXT: move $fp, $a0
438 ; LA64LARGE-NEXT: pcalau12i $a0, %gd_pc_hi20(gd)
439 ; LA64LARGE-NEXT: addi.d $a1, $zero, %got_pc_lo12(gd)
440 ; LA64LARGE-NEXT: lu32i.d $a1, %got64_pc_lo20(gd)
441 ; LA64LARGE-NEXT: lu52i.d $a1, $a1, %got64_pc_hi12(gd)
442 ; LA64LARGE-NEXT: move $s1, $zero
443 ; LA64LARGE-NEXT: add.d $s0, $a1, $a0
444 ; LA64LARGE-NEXT: .p2align 4, , 16
445 ; LA64LARGE-NEXT: .LBB5_1: # %loop
446 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
447 ; LA64LARGE-NEXT: move $a0, $s0
448 ; LA64LARGE-NEXT: pcalau12i $a1, %got_pc_hi20(__tls_get_addr)
449 ; LA64LARGE-NEXT: addi.d $ra, $zero, %got_pc_lo12(__tls_get_addr)
450 ; LA64LARGE-NEXT: lu32i.d $ra, %got64_pc_lo20(__tls_get_addr)
451 ; LA64LARGE-NEXT: lu52i.d $ra, $ra, %got64_pc_hi12(__tls_get_addr)
452 ; LA64LARGE-NEXT: ldx.d $ra, $ra, $a1
453 ; LA64LARGE-NEXT: jirl $ra, $ra, 0
454 ; LA64LARGE-NEXT: ld.w $zero, $a0, 0
455 ; LA64LARGE-NEXT: addi.w $s1, $s1, 1
456 ; LA64LARGE-NEXT: blt $s1, $fp, .LBB5_1
457 ; LA64LARGE-NEXT: # %bb.2: # %ret
458 ; LA64LARGE-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
459 ; LA64LARGE-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
460 ; LA64LARGE-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
461 ; LA64LARGE-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
462 ; LA64LARGE-NEXT: addi.d $sp, $sp, 32
463 ; LA64LARGE-NEXT: ret
468 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
469 %0 = load volatile i32, ptr @gd, align 4
470 %inc = add nuw nsw i32 %i, 1
471 %cmp = icmp slt i32 %inc, %n
472 br i1 %cmp, label %loop, label %ret