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: addi.w $a2, $a2, %pc_lo12(l)
19 ; LA32-NEXT: .p2align 4, , 16
20 ; LA32-NEXT: .LBB0_1: # %loop
21 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
22 ; LA32-NEXT: ld.w $zero, $a2, 0
23 ; LA32-NEXT: addi.w $a1, $a1, 1
24 ; LA32-NEXT: blt $a1, $a0, .LBB0_1
25 ; LA32-NEXT: # %bb.2: # %ret
28 ; LA64-LABEL: test_la_pcrel:
29 ; LA64: # %bb.0: # %entry
30 ; LA64-NEXT: move $a1, $zero
31 ; LA64-NEXT: pcalau12i $a2, %pc_hi20(l)
32 ; LA64-NEXT: addi.d $a2, $a2, %pc_lo12(l)
33 ; LA64-NEXT: .p2align 4, , 16
34 ; LA64-NEXT: .LBB0_1: # %loop
35 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
36 ; LA64-NEXT: ld.w $zero, $a2, 0
37 ; LA64-NEXT: addi.w $a1, $a1, 1
38 ; LA64-NEXT: blt $a1, $a0, .LBB0_1
39 ; LA64-NEXT: # %bb.2: # %ret
42 ; LA64LARGE-LABEL: test_la_pcrel:
43 ; LA64LARGE: # %bb.0: # %entry
44 ; LA64LARGE-NEXT: move $a1, $zero
45 ; LA64LARGE-NEXT: pcalau12i $a2, %pc_hi20(l)
46 ; LA64LARGE-NEXT: addi.d $t8, $zero, %pc_lo12(l)
47 ; LA64LARGE-NEXT: lu32i.d $t8, %pc64_lo20(l)
48 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %pc64_hi12(l)
49 ; LA64LARGE-NEXT: add.d $a2, $t8, $a2
50 ; LA64LARGE-NEXT: .p2align 4, , 16
51 ; LA64LARGE-NEXT: .LBB0_1: # %loop
52 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
53 ; LA64LARGE-NEXT: ld.w $zero, $a2, 0
54 ; LA64LARGE-NEXT: addi.w $a1, $a1, 1
55 ; LA64LARGE-NEXT: blt $a1, $a0, .LBB0_1
56 ; LA64LARGE-NEXT: # %bb.2: # %ret
62 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
63 %0 = load volatile i32, ptr @l, align 4
64 %inc = add nuw nsw i32 %i, 1
65 %cmp = icmp slt i32 %inc, %n
66 br i1 %cmp, label %loop, label %ret
72 @g = global i32 0, align 4
74 define void @test_la_got(i32 signext %n) {
75 ; LA32-LABEL: test_la_got:
76 ; LA32: # %bb.0: # %entry
77 ; LA32-NEXT: pcalau12i $a1, %got_pc_hi20(g)
78 ; LA32-NEXT: ld.w $a1, $a1, %got_pc_lo12(g)
79 ; LA32-NEXT: move $a2, $zero
80 ; LA32-NEXT: .p2align 4, , 16
81 ; LA32-NEXT: .LBB1_1: # %loop
82 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
83 ; LA32-NEXT: ld.w $zero, $a1, 0
84 ; LA32-NEXT: addi.w $a2, $a2, 1
85 ; LA32-NEXT: blt $a2, $a0, .LBB1_1
86 ; LA32-NEXT: # %bb.2: # %ret
89 ; LA64-LABEL: test_la_got:
90 ; LA64: # %bb.0: # %entry
91 ; LA64-NEXT: pcalau12i $a1, %got_pc_hi20(g)
92 ; LA64-NEXT: ld.d $a1, $a1, %got_pc_lo12(g)
93 ; LA64-NEXT: move $a2, $zero
94 ; LA64-NEXT: .p2align 4, , 16
95 ; LA64-NEXT: .LBB1_1: # %loop
96 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
97 ; LA64-NEXT: ld.w $zero, $a1, 0
98 ; LA64-NEXT: addi.w $a2, $a2, 1
99 ; LA64-NEXT: blt $a2, $a0, .LBB1_1
100 ; LA64-NEXT: # %bb.2: # %ret
103 ; LA64LARGE-LABEL: test_la_got:
104 ; LA64LARGE: # %bb.0: # %entry
105 ; LA64LARGE-NEXT: pcalau12i $a1, %got_pc_hi20(g)
106 ; LA64LARGE-NEXT: addi.d $t8, $zero, %got_pc_lo12(g)
107 ; LA64LARGE-NEXT: lu32i.d $t8, %got64_pc_lo20(g)
108 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %got64_pc_hi12(g)
109 ; LA64LARGE-NEXT: ldx.d $a1, $t8, $a1
110 ; LA64LARGE-NEXT: move $a2, $zero
111 ; LA64LARGE-NEXT: .p2align 4, , 16
112 ; LA64LARGE-NEXT: .LBB1_1: # %loop
113 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
114 ; LA64LARGE-NEXT: ld.w $zero, $a1, 0
115 ; LA64LARGE-NEXT: addi.w $a2, $a2, 1
116 ; LA64LARGE-NEXT: blt $a2, $a0, .LBB1_1
117 ; LA64LARGE-NEXT: # %bb.2: # %ret
118 ; LA64LARGE-NEXT: ret
123 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
124 %0 = load volatile i32, ptr @g, align 4
125 %inc = add nuw nsw i32 %i, 1
126 %cmp = icmp slt i32 %inc, %n
127 br i1 %cmp, label %loop, label %ret
133 @ie = external thread_local(initialexec) global i32
135 define void @test_la_tls_ie(i32 signext %n) {
136 ; LA32-LABEL: test_la_tls_ie:
137 ; LA32: # %bb.0: # %entry
138 ; LA32-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
139 ; LA32-NEXT: ld.w $a2, $a1, %ie_pc_lo12(ie)
140 ; LA32-NEXT: move $a1, $zero
141 ; LA32-NEXT: add.w $a2, $a2, $tp
142 ; LA32-NEXT: .p2align 4, , 16
143 ; LA32-NEXT: .LBB2_1: # %loop
144 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
145 ; LA32-NEXT: ld.w $zero, $a2, 0
146 ; LA32-NEXT: addi.w $a1, $a1, 1
147 ; LA32-NEXT: blt $a1, $a0, .LBB2_1
148 ; LA32-NEXT: # %bb.2: # %ret
151 ; LA64-LABEL: test_la_tls_ie:
152 ; LA64: # %bb.0: # %entry
153 ; LA64-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
154 ; LA64-NEXT: ld.d $a1, $a1, %ie_pc_lo12(ie)
155 ; LA64-NEXT: move $a2, $zero
156 ; LA64-NEXT: .p2align 4, , 16
157 ; LA64-NEXT: .LBB2_1: # %loop
158 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
159 ; LA64-NEXT: ldx.w $zero, $a1, $tp
160 ; LA64-NEXT: addi.w $a2, $a2, 1
161 ; LA64-NEXT: blt $a2, $a0, .LBB2_1
162 ; LA64-NEXT: # %bb.2: # %ret
165 ; LA64LARGE-LABEL: test_la_tls_ie:
166 ; LA64LARGE: # %bb.0: # %entry
167 ; LA64LARGE-NEXT: pcalau12i $a1, %ie_pc_hi20(ie)
168 ; LA64LARGE-NEXT: addi.d $t8, $zero, %ie_pc_lo12(ie)
169 ; LA64LARGE-NEXT: lu32i.d $t8, %ie64_pc_lo20(ie)
170 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %ie64_pc_hi12(ie)
171 ; LA64LARGE-NEXT: ldx.d $a1, $t8, $a1
172 ; LA64LARGE-NEXT: move $a2, $zero
173 ; LA64LARGE-NEXT: .p2align 4, , 16
174 ; LA64LARGE-NEXT: .LBB2_1: # %loop
175 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
176 ; LA64LARGE-NEXT: ldx.w $zero, $a1, $tp
177 ; LA64LARGE-NEXT: addi.w $a2, $a2, 1
178 ; LA64LARGE-NEXT: blt $a2, $a0, .LBB2_1
179 ; LA64LARGE-NEXT: # %bb.2: # %ret
180 ; LA64LARGE-NEXT: ret
185 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
186 %0 = load volatile i32, ptr @ie, align 4
187 %inc = add nuw nsw i32 %i, 1
188 %cmp = icmp slt i32 %inc, %n
189 br i1 %cmp, label %loop, label %ret
195 @ld = external thread_local(localdynamic) global i32
197 define void @test_la_tls_ld(i32 signext %n) {
198 ; LA32-LABEL: test_la_tls_ld:
199 ; LA32: # %bb.0: # %entry
200 ; LA32-NEXT: addi.w $sp, $sp, -16
201 ; LA32-NEXT: .cfi_def_cfa_offset 16
202 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
203 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
204 ; LA32-NEXT: st.w $s0, $sp, 4 # 4-byte Folded Spill
205 ; LA32-NEXT: st.w $s1, $sp, 0 # 4-byte Folded Spill
206 ; LA32-NEXT: .cfi_offset 1, -4
207 ; LA32-NEXT: .cfi_offset 22, -8
208 ; LA32-NEXT: .cfi_offset 23, -12
209 ; LA32-NEXT: .cfi_offset 24, -16
210 ; LA32-NEXT: move $fp, $a0
211 ; LA32-NEXT: move $s1, $zero
212 ; LA32-NEXT: pcalau12i $a0, %ld_pc_hi20(ld)
213 ; LA32-NEXT: addi.w $s0, $a0, %got_pc_lo12(ld)
214 ; LA32-NEXT: .p2align 4, , 16
215 ; LA32-NEXT: .LBB3_1: # %loop
216 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
217 ; LA32-NEXT: move $a0, $s0
218 ; LA32-NEXT: bl %plt(__tls_get_addr)
219 ; LA32-NEXT: ld.w $zero, $a0, 0
220 ; LA32-NEXT: addi.w $s1, $s1, 1
221 ; LA32-NEXT: blt $s1, $fp, .LBB3_1
222 ; LA32-NEXT: # %bb.2: # %ret
223 ; LA32-NEXT: ld.w $s1, $sp, 0 # 4-byte Folded Reload
224 ; LA32-NEXT: ld.w $s0, $sp, 4 # 4-byte Folded Reload
225 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
226 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
227 ; LA32-NEXT: addi.w $sp, $sp, 16
230 ; LA64-LABEL: test_la_tls_ld:
231 ; LA64: # %bb.0: # %entry
232 ; LA64-NEXT: addi.d $sp, $sp, -32
233 ; LA64-NEXT: .cfi_def_cfa_offset 32
234 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
235 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
236 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
237 ; LA64-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
238 ; LA64-NEXT: .cfi_offset 1, -8
239 ; LA64-NEXT: .cfi_offset 22, -16
240 ; LA64-NEXT: .cfi_offset 23, -24
241 ; LA64-NEXT: .cfi_offset 24, -32
242 ; LA64-NEXT: move $fp, $a0
243 ; LA64-NEXT: move $s1, $zero
244 ; LA64-NEXT: pcalau12i $a0, %ld_pc_hi20(ld)
245 ; LA64-NEXT: addi.d $s0, $a0, %got_pc_lo12(ld)
246 ; LA64-NEXT: .p2align 4, , 16
247 ; LA64-NEXT: .LBB3_1: # %loop
248 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
249 ; LA64-NEXT: move $a0, $s0
250 ; LA64-NEXT: bl %plt(__tls_get_addr)
251 ; LA64-NEXT: ld.w $zero, $a0, 0
252 ; LA64-NEXT: addi.w $s1, $s1, 1
253 ; LA64-NEXT: blt $s1, $fp, .LBB3_1
254 ; LA64-NEXT: # %bb.2: # %ret
255 ; LA64-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
256 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
257 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
258 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
259 ; LA64-NEXT: addi.d $sp, $sp, 32
262 ; LA64LARGE-LABEL: test_la_tls_ld:
263 ; LA64LARGE: # %bb.0: # %entry
264 ; LA64LARGE-NEXT: addi.d $sp, $sp, -32
265 ; LA64LARGE-NEXT: .cfi_def_cfa_offset 32
266 ; LA64LARGE-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
267 ; LA64LARGE-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
268 ; LA64LARGE-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
269 ; LA64LARGE-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
270 ; LA64LARGE-NEXT: .cfi_offset 1, -8
271 ; LA64LARGE-NEXT: .cfi_offset 22, -16
272 ; LA64LARGE-NEXT: .cfi_offset 23, -24
273 ; LA64LARGE-NEXT: .cfi_offset 24, -32
274 ; LA64LARGE-NEXT: move $fp, $a0
275 ; LA64LARGE-NEXT: move $s1, $zero
276 ; LA64LARGE-NEXT: pcalau12i $s0, %ld_pc_hi20(ld)
277 ; LA64LARGE-NEXT: addi.d $t8, $zero, %got_pc_lo12(ld)
278 ; LA64LARGE-NEXT: lu32i.d $t8, %got64_pc_lo20(ld)
279 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %got64_pc_hi12(ld)
280 ; LA64LARGE-NEXT: add.d $s0, $t8, $s0
281 ; LA64LARGE-NEXT: .p2align 4, , 16
282 ; LA64LARGE-NEXT: .LBB3_1: # %loop
283 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
284 ; LA64LARGE-NEXT: move $a0, $s0
285 ; LA64LARGE-NEXT: pcalau12i $ra, %pc_hi20(__tls_get_addr)
286 ; LA64LARGE-NEXT: addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
287 ; LA64LARGE-NEXT: lu32i.d $t8, %pc64_lo20(__tls_get_addr)
288 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
289 ; LA64LARGE-NEXT: add.d $ra, $t8, $ra
290 ; LA64LARGE-NEXT: jirl $ra, $ra, 0
291 ; LA64LARGE-NEXT: ld.w $zero, $a0, 0
292 ; LA64LARGE-NEXT: addi.w $s1, $s1, 1
293 ; LA64LARGE-NEXT: blt $s1, $fp, .LBB3_1
294 ; LA64LARGE-NEXT: # %bb.2: # %ret
295 ; LA64LARGE-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
296 ; LA64LARGE-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
297 ; LA64LARGE-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
298 ; LA64LARGE-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
299 ; LA64LARGE-NEXT: addi.d $sp, $sp, 32
300 ; LA64LARGE-NEXT: ret
305 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
306 %0 = load volatile i32, ptr @ld, align 4
307 %inc = add nuw nsw i32 %i, 1
308 %cmp = icmp slt i32 %inc, %n
309 br i1 %cmp, label %loop, label %ret
315 @le = external thread_local(localexec) global i32
317 define void @test_la_tls_le(i32 signext %n) {
318 ; LA32-LABEL: test_la_tls_le:
319 ; LA32: # %bb.0: # %entry
320 ; LA32-NEXT: move $a1, $zero
321 ; LA32-NEXT: lu12i.w $a2, %le_hi20(le)
322 ; LA32-NEXT: ori $a2, $a2, %le_lo12(le)
323 ; LA32-NEXT: add.w $a2, $a2, $tp
324 ; LA32-NEXT: .p2align 4, , 16
325 ; LA32-NEXT: .LBB4_1: # %loop
326 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
327 ; LA32-NEXT: ld.w $zero, $a2, 0
328 ; LA32-NEXT: addi.w $a1, $a1, 1
329 ; LA32-NEXT: blt $a1, $a0, .LBB4_1
330 ; LA32-NEXT: # %bb.2: # %ret
333 ; LA64-LABEL: test_la_tls_le:
334 ; LA64: # %bb.0: # %entry
335 ; LA64-NEXT: move $a1, $zero
336 ; LA64-NEXT: lu12i.w $a2, %le_hi20(le)
337 ; LA64-NEXT: ori $a2, $a2, %le_lo12(le)
338 ; LA64-NEXT: .p2align 4, , 16
339 ; LA64-NEXT: .LBB4_1: # %loop
340 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
341 ; LA64-NEXT: ldx.w $zero, $a2, $tp
342 ; LA64-NEXT: addi.w $a1, $a1, 1
343 ; LA64-NEXT: blt $a1, $a0, .LBB4_1
344 ; LA64-NEXT: # %bb.2: # %ret
347 ; LA64LARGE-LABEL: test_la_tls_le:
348 ; LA64LARGE: # %bb.0: # %entry
349 ; LA64LARGE-NEXT: move $a1, $zero
350 ; LA64LARGE-NEXT: lu12i.w $a2, %le_hi20(le)
351 ; LA64LARGE-NEXT: ori $a2, $a2, %le_lo12(le)
352 ; LA64LARGE-NEXT: lu32i.d $a2, %le64_lo20(le)
353 ; LA64LARGE-NEXT: lu52i.d $a2, $a2, %le64_hi12(le)
354 ; LA64LARGE-NEXT: .p2align 4, , 16
355 ; LA64LARGE-NEXT: .LBB4_1: # %loop
356 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
357 ; LA64LARGE-NEXT: ldx.w $zero, $a2, $tp
358 ; LA64LARGE-NEXT: addi.w $a1, $a1, 1
359 ; LA64LARGE-NEXT: blt $a1, $a0, .LBB4_1
360 ; LA64LARGE-NEXT: # %bb.2: # %ret
361 ; LA64LARGE-NEXT: ret
366 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
367 %0 = load volatile i32, ptr @le, align 4
368 %inc = add nuw nsw i32 %i, 1
369 %cmp = icmp slt i32 %inc, %n
370 br i1 %cmp, label %loop, label %ret
376 @gd = external thread_local global i32
378 define void @test_la_tls_gd(i32 signext %n) nounwind {
379 ; LA32-LABEL: test_la_tls_gd:
380 ; LA32: # %bb.0: # %entry
381 ; LA32-NEXT: addi.w $sp, $sp, -16
382 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
383 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
384 ; LA32-NEXT: st.w $s0, $sp, 4 # 4-byte Folded Spill
385 ; LA32-NEXT: st.w $s1, $sp, 0 # 4-byte Folded Spill
386 ; LA32-NEXT: move $fp, $a0
387 ; LA32-NEXT: move $s1, $zero
388 ; LA32-NEXT: pcalau12i $a0, %gd_pc_hi20(gd)
389 ; LA32-NEXT: addi.w $s0, $a0, %got_pc_lo12(gd)
390 ; LA32-NEXT: .p2align 4, , 16
391 ; LA32-NEXT: .LBB5_1: # %loop
392 ; LA32-NEXT: # =>This Inner Loop Header: Depth=1
393 ; LA32-NEXT: move $a0, $s0
394 ; LA32-NEXT: bl %plt(__tls_get_addr)
395 ; LA32-NEXT: ld.w $zero, $a0, 0
396 ; LA32-NEXT: addi.w $s1, $s1, 1
397 ; LA32-NEXT: blt $s1, $fp, .LBB5_1
398 ; LA32-NEXT: # %bb.2: # %ret
399 ; LA32-NEXT: ld.w $s1, $sp, 0 # 4-byte Folded Reload
400 ; LA32-NEXT: ld.w $s0, $sp, 4 # 4-byte Folded Reload
401 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
402 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
403 ; LA32-NEXT: addi.w $sp, $sp, 16
406 ; LA64-LABEL: test_la_tls_gd:
407 ; LA64: # %bb.0: # %entry
408 ; LA64-NEXT: addi.d $sp, $sp, -32
409 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
410 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
411 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
412 ; LA64-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
413 ; LA64-NEXT: move $fp, $a0
414 ; LA64-NEXT: move $s1, $zero
415 ; LA64-NEXT: pcalau12i $a0, %gd_pc_hi20(gd)
416 ; LA64-NEXT: addi.d $s0, $a0, %got_pc_lo12(gd)
417 ; LA64-NEXT: .p2align 4, , 16
418 ; LA64-NEXT: .LBB5_1: # %loop
419 ; LA64-NEXT: # =>This Inner Loop Header: Depth=1
420 ; LA64-NEXT: move $a0, $s0
421 ; LA64-NEXT: bl %plt(__tls_get_addr)
422 ; LA64-NEXT: ld.w $zero, $a0, 0
423 ; LA64-NEXT: addi.w $s1, $s1, 1
424 ; LA64-NEXT: blt $s1, $fp, .LBB5_1
425 ; LA64-NEXT: # %bb.2: # %ret
426 ; LA64-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
427 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
428 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
429 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
430 ; LA64-NEXT: addi.d $sp, $sp, 32
433 ; LA64LARGE-LABEL: test_la_tls_gd:
434 ; LA64LARGE: # %bb.0: # %entry
435 ; LA64LARGE-NEXT: addi.d $sp, $sp, -32
436 ; LA64LARGE-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
437 ; LA64LARGE-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
438 ; LA64LARGE-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
439 ; LA64LARGE-NEXT: st.d $s1, $sp, 0 # 8-byte Folded Spill
440 ; LA64LARGE-NEXT: move $fp, $a0
441 ; LA64LARGE-NEXT: move $s1, $zero
442 ; LA64LARGE-NEXT: pcalau12i $s0, %gd_pc_hi20(gd)
443 ; LA64LARGE-NEXT: addi.d $t8, $zero, %got_pc_lo12(gd)
444 ; LA64LARGE-NEXT: lu32i.d $t8, %got64_pc_lo20(gd)
445 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %got64_pc_hi12(gd)
446 ; LA64LARGE-NEXT: add.d $s0, $t8, $s0
447 ; LA64LARGE-NEXT: .p2align 4, , 16
448 ; LA64LARGE-NEXT: .LBB5_1: # %loop
449 ; LA64LARGE-NEXT: # =>This Inner Loop Header: Depth=1
450 ; LA64LARGE-NEXT: move $a0, $s0
451 ; LA64LARGE-NEXT: pcalau12i $ra, %pc_hi20(__tls_get_addr)
452 ; LA64LARGE-NEXT: addi.d $t8, $zero, %pc_lo12(__tls_get_addr)
453 ; LA64LARGE-NEXT: lu32i.d $t8, %pc64_lo20(__tls_get_addr)
454 ; LA64LARGE-NEXT: lu52i.d $t8, $t8, %pc64_hi12(__tls_get_addr)
455 ; LA64LARGE-NEXT: add.d $ra, $t8, $ra
456 ; LA64LARGE-NEXT: jirl $ra, $ra, 0
457 ; LA64LARGE-NEXT: ld.w $zero, $a0, 0
458 ; LA64LARGE-NEXT: addi.w $s1, $s1, 1
459 ; LA64LARGE-NEXT: blt $s1, $fp, .LBB5_1
460 ; LA64LARGE-NEXT: # %bb.2: # %ret
461 ; LA64LARGE-NEXT: ld.d $s1, $sp, 0 # 8-byte Folded Reload
462 ; LA64LARGE-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
463 ; LA64LARGE-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
464 ; LA64LARGE-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
465 ; LA64LARGE-NEXT: addi.d $sp, $sp, 32
466 ; LA64LARGE-NEXT: ret
471 %i = phi i32 [ %inc, %loop ], [ 0, %entry ]
472 %0 = load volatile i32, ptr @gd, align 4
473 %inc = add nuw nsw i32 %i, 1
474 %cmp = icmp slt i32 %inc, %n
475 br i1 %cmp, label %loop, label %ret