1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -ppc-asm-full-reg-names \
3 ; RUN: -mtriple powerpc64-ibm-aix-xcoff -mattr=+aix-small-local-exec-tls < %s \
4 ; RUN: | FileCheck %s --check-prefix=SMALL-LOCAL-EXEC-SMALLCM64
5 ; RUN: llc -verify-machineinstrs -mcpu=pwr7 -ppc-asm-full-reg-names \
6 ; RUN: -mtriple powerpc64-ibm-aix-xcoff --code-model=large \
7 ; RUN: -mattr=+aix-small-local-exec-tls < %s | FileCheck %s \
8 ; RUN: --check-prefix=SMALL-LOCAL-EXEC-LARGECM64
10 @ThreadLocalVarInit = thread_local(localexec) global i32 1, align 4
11 @VarInit = local_unnamed_addr global i32 87, align 4
12 @IThreadLocalVarInit = internal thread_local(localexec) global i32 1, align 4
13 declare nonnull ptr @llvm.threadlocal.address.p0(ptr nonnull) #1
14 %struct.anon = type { i32 }
15 @ThreadLocalStruct = thread_local(localexec) global %struct.anon zeroinitializer, align 1
16 @a = thread_local(localexec) global [87 x i32] zeroinitializer, align 4
18 define nonnull ptr @AddrTest1() local_unnamed_addr #0 {
19 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: AddrTest1:
20 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
21 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: la r3, a[TL]@le(r13)
22 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: addi r3, r3, 12
23 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
25 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: AddrTest1:
26 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
27 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: la r3, a[TL]@le(r13)
28 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: addi r3, r3, 12
29 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
31 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @a)
32 %arrayidx = getelementptr inbounds [87 x i32], ptr %0, i64 0, i64 3
36 define signext i32 @testUnaligned() {
37 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: testUnaligned:
38 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
39 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: la r3, ThreadLocalStruct[TL]@le(r13)
40 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwa r3, 0(r3)
41 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
43 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: testUnaligned:
44 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
45 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: la r3, ThreadLocalStruct[TL]@le(r13)
46 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwa r3, 0(r3)
47 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
49 %0 = call align 1 ptr @llvm.threadlocal.address.p0(ptr align 1 @ThreadLocalStruct)
50 %x = getelementptr inbounds %struct.anon, ptr %0, i32 0, i32 0
51 %1 = load i32, ptr %x, align 1
55 define void @storeITLInit(i32 noundef signext %x) {
56 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: storeITLInit:
57 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
58 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: stw r3, IThreadLocalVarInit[TL]@le(r13)
59 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
61 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: storeITLInit:
62 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
63 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: stw r3, IThreadLocalVarInit[TL]@le(r13)
64 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
66 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarInit)
67 store i32 %x, ptr %0, align 4
71 define void @storeTLInit(i32 noundef signext %x) {
72 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: storeTLInit:
73 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
74 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: stw r3, ThreadLocalVarInit[TL]@le(r13)
75 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
77 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: storeTLInit:
78 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
79 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: stw r3, ThreadLocalVarInit[TL]@le(r13)
80 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
82 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @ThreadLocalVarInit)
83 store i32 %x, ptr %0, align 4
87 define signext i32 @loadITLInit() {
88 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: loadITLInit:
89 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
90 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwa r3, IThreadLocalVarInit[TL]@le(r13)
91 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
93 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: loadITLInit:
94 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
95 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwa r3, IThreadLocalVarInit[TL]@le(r13)
96 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
98 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarInit)
99 %1 = load i32, ptr %0, align 4
103 define signext i32 @loadITLInit2() {
104 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: loadITLInit2:
105 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
106 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: ld r4, L..C0(r2) # @VarInit
107 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwz r3, IThreadLocalVarInit[TL]@le(r13)
108 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwz r4, 0(r4)
109 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: add r3, r4, r3
110 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: extsw r3, r3
111 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
113 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: loadITLInit2:
114 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
115 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: addis r4, L..C0@u(r2)
116 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwz r3, IThreadLocalVarInit[TL]@le(r13)
117 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: ld r4, L..C0@l(r4)
118 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwz r4, 0(r4)
119 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: add r3, r4, r3
120 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: extsw r3, r3
121 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
123 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarInit)
124 %1 = load i32, ptr %0, align 4
125 %2 = load i32, ptr @VarInit, align 4
126 %add = add nsw i32 %2, %1
130 define signext i32 @loadTLInit() {
131 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: loadTLInit:
132 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
133 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwa r3, ThreadLocalVarInit[TL]@le(r13)
134 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
136 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: loadTLInit:
137 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
138 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwa r3, ThreadLocalVarInit[TL]@le(r13)
139 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
141 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @ThreadLocalVarInit)
142 %1 = load i32, ptr %0, align 4
146 define signext i32 @loadTLInit2() {
147 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: loadTLInit2:
148 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
149 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: ld r4, L..C0(r2) # @VarInit
150 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwz r3, ThreadLocalVarInit[TL]@le(r13)
151 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwz r4, 0(r4)
152 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: add r3, r4, r3
153 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: extsw r3, r3
154 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
156 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: loadTLInit2:
157 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
158 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: addis r4, L..C0@u(r2)
159 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwz r3, ThreadLocalVarInit[TL]@le(r13)
160 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: ld r4, L..C0@l(r4)
161 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwz r4, 0(r4)
162 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: add r3, r4, r3
163 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: extsw r3, r3
164 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
166 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @ThreadLocalVarInit)
167 %1 = load i32, ptr %0, align 4
168 %2 = load i32, ptr @VarInit, align 4
169 %add = add nsw i32 %2, %1
173 define void @loadStore1(i32 noundef signext %x) {
174 ; SMALL-LOCAL-EXEC-SMALLCM64-LABEL: loadStore1:
175 ; SMALL-LOCAL-EXEC-SMALLCM64: # %bb.0: # %entry
176 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: lwz r3, IThreadLocalVarInit[TL]@le(r13)
177 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: addi r3, r3, 9
178 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: stw r3, IThreadLocalVarInit[TL]@le(r13)
179 ; SMALL-LOCAL-EXEC-SMALLCM64-NEXT: blr
181 ; SMALL-LOCAL-EXEC-LARGECM64-LABEL: loadStore1:
182 ; SMALL-LOCAL-EXEC-LARGECM64: # %bb.0: # %entry
183 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: lwz r3, IThreadLocalVarInit[TL]@le(r13)
184 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: addi r3, r3, 9
185 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: stw r3, IThreadLocalVarInit[TL]@le(r13)
186 ; SMALL-LOCAL-EXEC-LARGECM64-NEXT: blr
188 %0 = tail call align 4 ptr @llvm.threadlocal.address.p0(ptr align 4 @IThreadLocalVarInit)
189 %1 = load i32, ptr %0, align 4
190 %add = add nsw i32 %1, 9
191 store i32 %add, ptr %0, align 4